总阅读量次
webpack 打包程序小案例
安装webpack
1 | npm install webpack -g |
新建项目
1 | mkdir demo && cd demo |
写入项目
webpack.config.js
1 | const path = require('path'); |
src/index.js
1 | const greet = require('./Greeter.js'); |
src/Greeter.js
1 | module.exports = function() { |
public/index.html
1 |
|
insert into package.json
1 | "scripts": { |
报错调试

这是因为webpack版本过高导致的结果,使用下面的命令进行打包,可以解决
1 | webpack ./src/index.js -o ./dist/bundle.js |
其中 bundle.js是打包后生成的文件的文件名