javascript - ExtractTextPlugin 无法单独打包css,请码友帮忙解决。
PHP中文网
PHP中文网 2017-04-11 12:40:14
0
1
568

初次使用ExtractTextPlugin,发现单独打包css时失效(打包结束后的built路径下,没有app.css文件):

module.exports = {
    entry:{
        main:"./app/index.jsx",
        vendor:[
            "react",
            "react-dom",
            "react-router",
            "react-bootstrap",
            "underscore",
        ]
    },
    output: {
        path: path.resolve(__dirname, './built'),
        filename: '[name].js?[chunkhash]',
        chunkFilename: '[name].js?[chunkhash]',
        publicPath: './built/'
      },
      resolve: {
        // modulesDirectories: [ 'node_modules' ],
        extensions: ['.js', '.jsx']
     },
      module: {
        loaders: [
          {
            test: /\.jsx|js$/,
            loader: 'babel-loader',
            exclude: /(node_modules|bower_components)/,
            query: {
              presets: ['es2015', 'react']
            }
          },
          {
            test: /\.css|scss$/,
            loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css!scss' })
          },    
          {
            test: /\.png|jpg|gif|jpeg$/,
            loader: "url-loader?limit=8194&name=img/[name].[ext]",
            query: 'random=' + new Date().getTime(),
          },
          {
            test: /\.json$/,
            loader: "json"
          }
        ],
  },
plugins:[
     new ExtractTextPlugin({ filename: './app.css', disable: false, allChunks: true })
    ]
}
PHP中文网
PHP中文网

认证0级讲师

répondre à tous(1)
Peter_Zhu

你把这个{ filename: './app.css', disable: false, allChunks: true }换成直接的路径试试
例如 (‘css/[name].css’)

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal