5

I have inherited an angular+Typescript project. The dev environment used gulp's webserver and I am trying to switch over to webpack-dev-server so that we can enable hot-module-replacement.

When I run webpack-dev-server from our build/ directory, the command fails, listing about 700 TypeScript errors. We would rather not fix them. Is there any way to use webpack-dev-server even with TypeScript errors?

My understanding was that webpack should still correctly create the build file and start the dev-server even if typescript errors occur, unless you enable the webpack-fail-plugin, which I do not have enabled.

Here is my current webpack.config.js file:

'use strict';
var webpack = require('webpack');
var CompressionPlugin = require("compression-webpack-plugin");

var config = {
    entry: {
        build:  './app/core/bootstrap.ts',
        //adminbuild: './app/core/adminbootstrap.ts',
        //report: './app/core/reportbootstrap.ts',
        vendor: ["angular", "angular-material"]
    },

    output: {
        path: __dirname + '/build',
        publicPath: '',
        filename: '[name].bundle.js'
    },

    devtool: 'source-map',

    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.ts', '.js', '.json', '.jsx', '.js']
    },

    module: {
        preloaders: [
           /* {
                test: /\.ts$/,
                loader: 'tslint'
            }*/
        ],

        loaders: [
        ...
            {
                test: /\.ts$/,
                loader: 'ts'
            },
        ...
        ],
    },
};

module.exports = config;

1 Answer 1

-4

unless you enable the webpack-fail-plugin, which I do not have enabled.

Not true. Webpack 2 fails builds on typescript errors by default.

More

https://www.npmjs.com/package/webpack-fail-plugin mentions this fact DEPRECATED: This is default behaviour in Webpack 2.x, you don't need this plugin anymore.

Suggestion: Fix the TypeScript errors.

1
  • 2
    This is NOT true. Webpack 2 does not fail build on typescript error. The TS loader itself still fails to propagate TS errors by throwing them to webpack, hence, webpack 2 has not solved this issue.
    – Kim Gentes
    Jun 8, 2017 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.