A
A
Alexey2017-04-08 17:55:16
webpack
Alexey, 2017-04-08 17:55:16

Webpack Server does not collect .js, what to do with it?

Webpack-dev-server 2.4.2 does not bundle .js (in my case it is bundle.js). When launched, everything outputs to the terminal without errors, writes "successful", but there is no result - it displays the unchanged bundle.js When
requesting the webpack command, without running locally, everything works without errors, the assembly occurs. Do not remain indifferent to this issue, in the open spaces of the network this problem is not uncommon.

const ExtractTextPlugin = require('extract-text-webpack-plugin');
var path = require('path');

module.exports = {
    entry: './src/app.js',
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname),
        publicPath: path.resolve(__dirname, './static')
        // path: __dirname + '/bundle'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: [/node_modules/],
                use: [{
                    loader: 'babel-loader',
                    options: { presets: ['es2015'] }
                }]
            },
            {
                test: /\.css$/,
                use: ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    use: 'css-loader'
                })
            }
        ]
    },
    devServer: {
        contentBase: path.join(__dirname, "dist"),
        compress: true,
        stats: "errors-only",
        open: true
    },
    // devServer: {

    // },
    plugins: [
        new ExtractTextPlugin('styles.css')
    ]
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Manakov, 2017-04-08
@aleksmanson

Mb the problem is that your bundle.js is simply cached.
Try this
It adds hash to the filename and changes it on every rebuild so the bundle is reloaded every time.
Plus, you don't need to write the names of js files in index.html. It helps a lot when there are several.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question