[In] webpack enforce the use of

Loader writing order is important, because a single, used in combination with the principle of responsibility loader, a loader order all of a very important process

 

How to adjust this sequence is very important, but if you write the time has lined up order, it does not matter, such as this

  module: {
    rules: [
      {
        test: /\.less$/,
        use: 'style-loader'
      },
     {
        test: /\.less$/,
        use: 'css-loader'
      },
     {
        test: /\.less$/,
        use: 'less-loader'
      }
    ]
  },

The default is processed from the Kings

 

By a  enforce  attributes, the default values are as follows

. 1 . Pre priority
 2 . Normal Normal (default)
 . 3 . Next inline process
 . 4 . POST final treatment

 

By setting this value to reorder

module: {
    rules: [
      {
        test: /\.less$/,
        use: 'less-loader',
        enforce: 'pre'
      },
     {
        test: /\.less$/,
        use: 'css-loader'
      },
     {
        test: /\.less$/,
        use: 'style-loader',
        enforce: 'post'
      }
    ]
  },

 

Guess you like

Origin www.cnblogs.com/wuxianqiang/p/11332590.html