窗口未使用css加载器定义

时间:2017-11-25 01:03:15

标签: javascript reactjs webpack css-loader

当我想在我的webpack配置中放置一个css加载器时,我有这个错误:

  

返回窗口&&文件&& document.all&& !window.atob;                   ^

     

ReferenceError:未定义窗口

问题我不能使用任何使用css的自定义组件因为这个。 我的webpack.config.js是这样的:

const path = require("path")
const webpack = require("webpack")

module.exports = {
entry: [
    "react-hot-loader/patch",
    "webpack-dev-server/client?http://localhost:8080",
    "webpack/hot/only-dev-server",
    "./src/browser/index.js"
],
output: {
    path: path.resolve(__dirname, "build", "assets"),
    filename: "app.min.js",
    publicPath: "/assets/",
    libraryTarget: 'var',
    library: 'className'
},
module: {
    loaders: [
        {
            test: /\.js$/,
            loader: "babel-loader"
        },
        {
            test: /\.(jpe?g|png|gif|svg|ico)$/i,
            loaders: [
                'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
                'image-webpack-loader'
            ]
        },
        {
            test: /\.css$/,
            loader: "style-loader!css-loader"
        }

    ]
}

,
plugins: [
    new webpack.HotModuleReplacementPlugin()
],
resolve: {
    alias: {
        component: path.resolve(__dirname, "src", "component"),
        actions: path.resolve(__dirname, "src", "actions"),
        reducers: path.resolve(__dirname, "src", "reducers"),
        store: path.resolve(__dirname, "src", "store")
    }
},
devServer: {
    host: "localhost",
    port: 8080,
    hot: true,
    proxy: {
        "**": "http://localhost:3000"
    }
}
};

你有什么想法吗?

0 个答案:

没有答案