webpack 4.0 配置文件 webpack.config.js文件的放置位置
一般webpack.config.js是默认放在根目录的,不在根目录的时候需要在package.json中制定位置,我的配置文件目录是config/webpack.config.js,在package.json文件中的配置为:
"scripts": { "build": "webpack --mode production --config ./config/webpack.config.js", "dev": "webpack --mode development --config ./config/webpack.config.js" },
webpack.config.js文件中需要定义上下文地址为:
const path = require('path') module.exports = { //context:path.resolve(__dirname,'../'),这句不需要, __dirname指定的就是根目录 entry: { app: ['./src/index.js'], about: ['./src/about.js'] }, output: { path: path.resolve(__dirname,'../dist'), filename: '[name].js', } };