webpack three operating modes

The first:

  No webpack.cofig.js file when using the default configuration file from the command line input npx webpack index.js (interface file for the index.js)

The second:

  There webpack.cofig.js input file on the command line npx webpack

the require path = const ( 'path' ); 
module.exports = { 
    entry: './src/index.js' , 
    Output: { 
        // interface file generated 
        filename: 'bundle.js' ,
         // the bundle generated. dist js file in the file 
        path: path.resolve (__ dirname, 'dist' ) 
    } 
}

 Third:

   There webpack.cofig.js file on the command line, type npx run bundle (need to change package.json

{
  "name": "webpackcase",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {
    "bundle": "webpack"//更改的部分
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "webpack": "^4.37.0",
    "webpack-cli": "^3.3.6"
  }
}

 

)

Guess you like

Origin www.cnblogs.com/rickyctbur/p/11262278.html