我有预制项目,它运行正常,但是当我编辑文件api / index.php时webpack正在重建项目,而当我没有因为。#index.php文件而没有将文件保存在emacs中时失败。
如何忽略api
目录或仅忽略app
目录中的文件?我需要从根目录复制文件,因此我无法使用context
,因为webpack不会在根目录中看到index.html或.htaccess等文件。
这是我的webpack配置文件:
module.exports = {
entry: {
app: path.resolve('./app') + '/app.jsx'
},
output: {
path: path.resolve('./dist'),
filename: "[name].js"
},
plugins: ([
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
minChunks: isNodeModule
}),
new webpack.DefinePlugin({
PRODUCTION: ENV === 'production'
}),
new CopyWebpackPlugin([
{from: 'index.html'},
{from: '.htaccess'},
{from: 'config.json'},
{from: 'api', to: 'api'}
])
]).concat(ENV==='production' ? [
new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
},
compress: {
unsafe_comps: true,
properties: true,
keep_fargs: false,
pure_getters: true,
collapse_vars: true,
unsafe: true,
warnings: false,
screw_ie8: true,
sequences: true,
dead_code: true,
drop_debugger: true,
comparisons: true,
conditionals: true,
evaluate: true,
booleans: true,
loops: true,
unused: true,
hoist_funs: true,
if_return: true,
join_vars: true,
cascade: true,
drop_console: true
}
})
] : []),
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
}
]
},
resolve: {
extensions: ['.jsx', '.js', '.json']
},
devServer: {
historyApiFallback: true,
open: true
}
};
编辑:看起来这与dev-server无关,因为当我在Emacs中有未保存的文件时,我也无法运行webpack。