我已经多次尝试使用--watch标志在监视模式下运行webpack但是当条目文件发生更改时它会重新绑定,这里是我的配置文件
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, "dev/App.js"),
output: {
path: __dirname,
filename: 'public/bundle.js'
},
module: {
// configuration regarding modules
rules: [
// rules for modules (configure loaders, parser options, etc.)
{
test: /\.jsx?$/,
exclude: [
path.resolve(__dirname, "node_modules")
],
// these are matching conditions, each accepting a regular expression or string
// conditions for the issuer (the origin of the import)
loader: "babel-loader",
// the loader which should be applied, it'll be resolved relative to the context
// -loader suffix is no longer optional in webpack2 for clarity reasons
// see webpack 1 upgrade guide
options: {
presets: ["es2015","react"]
},
// options for the loader
}]
},
resolve: {
extensions: ['.js', '.jsx']
},
watchOptions: {
aggregateTimeout: 300, // in ms
// aggregates multiple changes to a single rebuild
poll: 300, // intervall in ms
// enables polling mode for watching
// must be used on filesystems that doesn't notify on change
// i. e. nfs shares
}
};
相同的配置文件在Linux上工作得很好,但我不知道为什么它在Windows 10 64bit上不起作用,顺便说一下我使用v2.2.0,v2.2.1,v1.13.1和其他一些我的webpack版本不记得,它们都不起作用:S