我在使用webpack 4.0 以上版本打包时,发现在webpack.config.js的output选项中指定filename,打包出来的结果却总是main.js, 这是为什么啊?有没有大神指点迷津?
下面附图和代码:
//这是webpack.config.js内容
var path = require("path")
module.export = {
entry: path.resolve(__dirname, "./index.js"),
output: {
path: path.resolve(__dirname, "./dist"),
filename: '.js/bundle.[name].[hash].js'
}
}
//这里是package.json代码
{
"name": "webpack-practice-singlepage",
"version": "1.0.0",
"description": "this project is for spa practice",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack --mode=development",
"build": "webpack --mode=production"
},
"author": "Manfray",
"license": "ISC",
"devDependencies": {
"webpack": "^4.5.0",
"webpack-cli": "^2.0.14"
}
}
然后我npm run dev 之后,项目目录中就生成了dist dist/main.js
那么我这个filename怎么没有起作用呢?
weixin_慕田峪1008439
染丶墨3614535
守着一只汪
相关分类