问 题
var htmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
// var webpackMerge = require('webpack-merge');
module.exports = {
entry: './src/main.js',
output:{
filename:'./dist/bundle-[hash].js'
},
module: {
loaders: [
{
test: /\.css$/,
loaders: ["style-loader", "css-loader"],
},
{
test: /\.js$/,
loader: "babel-loader",
// include: '/src/static/views/'
},
{
test: /\.html$/,
loader: "html-loader"
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader'
}
]
},
plugins: [
new webpack.ProvidePlugin({
_ : 'underscore',
$ : 'webpack-zepto',
Zepto : 'webpack-zepto',
'window.Zepto': 'webpack-zepto',
'window.$': 'webpack-zepto',
fastclick : 'fastclick'
})
],
externals: {
zepto: 'window.$'
}
};
解决方案
The reason you are seeing this is because the output.filename property is supposed to only contain the name of the file itself.
What is happening is that webpack is assuming the folder path before it, and then using the [hash] id of the lazy loaded bundles you are creating as the folder names.
My best guess would be that you could instead change this to:
const path = require('path');
module.exports = {
// ...
output: {
path: path.join(__dirname, "dist"),
filename: "bundle-[hash].js"
}
// ...
};
扫一扫关注IT屋
微信公众号搜索 “ IT屋 ” ,选择关注与百万开发者在一起