bwalker
bwalker

Reputation: 73

webpack-dev-server rebuilds very slow

I'm having a performance issue when using webpack-dev-server to compile my asset. For some reason, webpack-dev-server is very slow at rebuilding. webpack -watch is about 90% faster.

my webpack config:

var webpackConfig = {
                    entry: {
                        router: [
                            'webpack-dev-server/client?https://localhost:3000',
                            'webpack/hot/only-dev-server',
                            '<%= pkg.main %>'
                        ]
                    },
                    output: {
                        filename: './js/v2/bundle.js',
                        publicPath: 'https://localhost:3000/'
                    },
                    module: {
                        loaders: moduleLoaders
                    },
                    resolve: {
                        root: jsFilePaths,
                        extensions: ['', '.js', '.jsx', '.css'],
                        alias: webpackAlias,
                        fallback: ["./node_modules"]
                    },
                    resolveLoader: {
                        root: path.join(__dirname, "node_modules")
                    },
                    devtool: 'eval-source-map',
                    watch: true,
                    profile: true,
                    json: true,
                    cache: true,
                    keepAlive: true,
                    plugins: [
                        new webpack.NoErrorsPlugin(),
                        new webpack.HotModuleReplacementPlugin()
                    ]
                };

My webpack-dev-server config (using grunt):

"webpack-dev-server": {
        options: {
            webpack: webpackConfig,
            publicPath: webpackConfig.output.publicPath,
            port: 3000,
            https:true,
            host: "localhost",
            contentBase: "https://localhost",
            hot: true,
            headers: { 'Access-Control-Allow-Origin': '*' }
        },
        start: {
            keepAlive: true
        }

It looks like webpack-dev-server is not using it's cache correctly or something. Any ideas would he really helpful.

Upvotes: 3

Views: 5585

Answers (1)

bwalker
bwalker

Reputation: 73

The problem was with in resolve:root.

Original jsFilePaths:

var jsFilePaths = [
                        'js/v2/components',
                        'js/v2/components/shared'
                    ];

New jsFilePaths:

var jsFilePaths = [
                        __dirname + path.sep + 'js\\v2\\components',
                        __dirname + path.sep + 'js\\v2\\components\\shared'
                    ];

Apparently this is only required if you are on Windows. Webpack doesn't seem to walk the dependencies if the path is unix format.

Upvotes: 4

Related Questions