我在使用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怎么没有起作用呢?
4 回答
染丶墨3614535
TA贡献1条经验 获得超0个赞
你的package.json中执行脚本webpack命令后面少了一个 --config 参数,表示用后面的文件作为webpack的执行配置文件,不然就会以默认的配置文件作为输出,也就一直是dist的main.js
添加回答
举报
0/150
提交
取消