相关疑难解决方法(0)

使用extract-text-webpack-plugin时,窗口未定义错误

我正在使用webpack来构建我的反应组件,我正在尝试使用extract-text-webpack-plugin它将我的css与生成的js文件分开.但是,当我尝试构建组件时,我收到以下错误: Module build failed: ReferenceError: window is not defined.

我的webpack.config.js文件如下所示:

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

module.exports = {
  entry: {
    MainComponent: './src/main.js'
  },
  output: {
    libraryTarget: 'var',
    library: 'MainComponent',
    path: './build',
    filename: '[name].js'
  },
  module: {
    loaders: [{
      test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader!css-loader')
    }]
  },
  plugins: [
    new ExtractTextPlugin('styles.css')
  ]
}
Run Code Online (Sandbox Code Playgroud)

reactjs webpack

82
推荐指数
4
解决办法
3万
查看次数

标签 统计

reactjs ×1

webpack ×1