◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
2.在package.json文件同级建立webpack.config.js文件,内容如下:
123456789 |
const path = require('path');module.exports = {entry: './src/index.js', // 入口output: { // 出口filename: 'bundle.js', // 文件名
path: path.resolve(__dirname, 'dist') // 生成路径
}}; |
123456789101112131415161718 |
{"name": "webpack-demo","version": "1.0.0","description": "","main": "index.js","scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
+ "build": "webpack" // 修改命令执行方法
},"keywords": [],"author": "","license": "ISC","devDependencies": {"webpack": "^4.0.1","webpack-cli": "^2.0.9","lodash": "^4.17.5"}} |
结论:生成类似下面的目录,打开index.html 有Hello webpack显示
123456789 |
webpack-demo|- package.json|- webpack.config.js|- /dist|- bundle.js|- index.html|- /src|- index.js|- /node_modules |
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。