webpack 默認(rèn)配置文件是 webpack.config.js
配置文件配置好后,就不用在執(zhí)行 webpack 時(shí),后面寫(xiě)執(zhí)行源文件和目標(biāo)文件路徑和名字,直接輸入webpack回車(chē)
也可以重命名webpack.config.js 如:webpack.dev.config.js,執(zhí)行webpack時(shí)需要 webpack --config webpack.dev.config.js
webpack.config.js
const path = require('path');
module.exports = {
entry: 'hello.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'hello_bundle.js'
}
};
如果需要加參數(shù),需要結(jié)合npm腳本進(jìn)行設(shè)置。
package.json
"scripts": {
"webpack":"webpack --config webpack.config.js --progress --display-modules --colors --display-reason"
}
npm run webpack