◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
2.在package.json文件同级建立webpack.config.js文件,内容如下:
1
2
3
4
5
6
7
8
9
|
const path = require('path');module.exports = {entry: './src/index.js', // 入口output: { // 出口filename: 'bundle.js', // 文件名path: path.resolve(__dirname, 'dist') // 生成路径}
};
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
{
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显示
1
2
3
4
5
6
7
8
9
|
webpack-demo|- package.json|- webpack.config.js|- /dist
|- bundle.js|- index.html|- /src
|- index.js|- /node_modules |
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。