简体   繁体   中英

Using Extract Text Plugin with Webpack

I'm trying to learn how to use Extract Text Plugin and I found this example:

var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  entry:  './src',
  output: {
    path: 'build',
    filename: 'bundle.js',
  },
  module: {
    loaders: [
      {
        test: /\.js/,
        loader: 'babel',
        include: __dirname + '/src',
      },
      {
        test: /\.css/,
        loader: ExtractTextPlugin.extract("css")
      }
    ],
  },
  plugins: [
    new ExtractTextPlugin("styles.css")
  ]
};

Why is the "css" used as a loader ? I tried to look at the docs but still can't understand this.

Thank you all in advance for your helps.

The extractTextPlugin can work with sass, less postcss etc so its asking plugin to only look for css . thats why you are using css there.

extractCSS.extract([ 'css-loader', 'postcss-loader' ])

extractLESS.extract([ 'css-loader', 'less-loader' ])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM