我在我们的 Rails 应用程序中使用 React 和 webpack 的 react-hot-loader 插件设置了 Webpack。它正在成功运行并构建bundle.js
我期望的文件,但它也在每次热更新时给我这样的文件0.bfeb31eda5c7e8da9473.hot-update.js
。我正在使用的一个插件的作者WriteFileWebpackPlugin
说,我可以在test
属性中告诉它不要监视.hot
其中的文件,但我不知道如何让它工作。
这是我的 webpack.config.js
var webpack = require('webpack')
var path = require('path')
var WriteFilePlugin = require('write-file-webpack-plugin')
module.exports = {
// watchOptions: {
// poll: true
// },
context: __dirname + '/app/assets/javascripts',
entry: {
App: [
'webpack-dev-server/client?http://localhost:8080/',
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'app/assets/source/index.js')
]
},
output: {
path: path.resolve(__dirname, 'app/assets/javascripts'),
publicPath: 'http://localhost:8080/',
filename: 'bundle.js'
},
module: {
loaders: [
{ test: /\.js$/,
loaders: ["react-hot", "babel"],
include: path.resolve(__dirname, 'app/assets/source')
}
]
},
devtool: 'inline-source-map',
devServer: {
outputPath: path.resolve(__dirname, 'app/assets/javascripts')
},
plugins: [
new WriteFilePlugin({test: /^.*[^\.].*\.js$/}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
}
有没有其他人遇到过这个?理想情况下,我想弄清楚test
如果可能的话,是否可以在没有该属性的情况下解决此问题,但即使只是弄清楚这一点也会有所帮助。