2

I notice that in production the bundle.js file is transferred twice. The second time is requested by the bundle.js file itself.. Is it by default or configuration related?

Also notice that the second time bundle.js is requested takes only 192ms, much less than 634ms on the first time. Maybe because the file is cached.

Note: This is an isomorphic app and restify is there to serve all assets files.

Check the screenshot bellow: enter image description here

Some of webpack production settings im using:

module.exports = {
    devtool: false,
    output: {
        path: resolve(__dirname, 'dist', 'www'),
        publicPath: '/www/',
        filename: 'bundle.js',
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({
            mangle: true,
            compress: {
                warnings: true,
                screw_ie8: true,
                conditionals: true,
                unused: true,
                comparisons: true,
                sequences: true,
                dead_code: true,
                evaluate: true,
                if_return: true,
                join_vars: true,
            },
            output: {
                comments: false,
            },
        }),
        new ExtractTextPlugin('styles.css'),
    ],
    module: {
        loaders: [{
            test: /\.js$/,
            loader: 'babel-loader',
            include: resolve(__dirname, 'src', 'main'),
            exclude: /node_modules/,
        }, {
            test: /\.*css$/,
            loader: ExtractTextPlugin.extract({
                fallback: 'style-loader', use: 'css-loader?-autoprefixer!sass-loader',
            }),
        }],
    }
};
Roberto14
  • 663
  • 4
  • 19
  • In the network tab you can see that the initiator for the xhr request of bundle.js is bundle.js itself, there's must be a call to that file in your bundle. Maybe try and remove the minification and read where bundle.js is mentionned in your bundle – Axnyff Apr 06 '17 at 15:21
  • @Axnyff It happens inside *retrieveSourceMapURL()* but I dont want to fetch sourceMaps in prodution, hence devtool is false.. :/ – Roberto14 Apr 07 '17 at 08:17

1 Answers1

1

The issue is related to sourceMaps fetching when Chrome Developer tools is opened. I tested with Charles Proxy as answer in another SO question (https://stackoverflow.com/a/30777461/2400247) and, in fact, bundle.js is downloaded only once.

Check the charles test below:

enter image description here

Hope it helps other devs.

Community
  • 1
  • 1
Roberto14
  • 663
  • 4
  • 19