16.打包命令除了webpack外,还可以在package.json中配置,配置内容如下
{
"name": "webpackapp",
"version": "1.0.0",
"description": "this is webpackapp",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"webpack"
},
"author": "suyan",
"license": "ISC",
"devDependencies": {
"webpack": "^2.2.1"
}
}
17.在命令行中我们不再使用webpack这个命令,改为cnpm start这个命令即可完成webpack的功能
cnpm start
18.在webpack的配置文件中配置source maps,修改webpack.config.js文件,添加devtool参数,修改内容如下
module.exports = {
entry: __dirname + "/app/Greeter.js",
output: {
path: __dirname + "/public",
filename: "bundle.js"
},
devtool:'eval-source-map'
}
19.在devtool参数添加前打包和添加后打包,生成的bundle.js文件对比
webpack