webpack打包 The 'mode' option has not been set, webpack will fallback to

webpack 打包报错 The 'mode' option has not been set, webpack will fallback to 'production' for,Module not found: Error: Can't resolve,WARNING in configuration

Operating environment:

  • windows
  • nodejs v10.15.3
  • webpack v4.38.0

I first global installed webpack and webpack-cli:

npm install -g webpack
npm install -g webpack-cli

 

Then run webpack being given to the packaging:

A closer look at the official website webpack manual discovery, starting from 4.0, when you run webpack sure to add parameters --mode Development [Development Environment ] or - the MODE Production's [ production ]:

Without using the configuration file usage

webpack <entry> [<entry>] -o <output>

<entry>

A file name or a group is named filename as the starting point of entry to build the project. You can pass multiple entry (each entry load at startup). If you pass a form  <name> = <request> of key-value pairs, you can create an additional entrance starting point. It will be mapped to the configuration options (configuration option) of the  entry property.

<output>

Path and file name of the bundled file to be saved. It will map to the configuration options  output.path and  output.filename.

Examples

webpack --mode development app.js -o bundle.js

 

If you have a configuration file ( webpack.config.js ), you can join mode.

module.exports = {
    mode: 'development'
}
 
Packing again:
 
 

success!

Attachment:

Configuration Options

parameter Explanation Input Type Defaults
--mode A used model, "development" or "production" among string  

 

Guess you like

Origin www.cnblogs.com/sirdong/p/11783775.html