css - webpack 2.7 不会加载 blueprintjs 核心 css

标签 css reactjs webpack-2 blueprintjs

我正在尝试使用 blueprintjs 并导入它的 css。我想我在我的 webpack 配置中犯了一些错误,所以我看到了这个错误 enter image description here

这是我的 webpack 配置

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

module.exports={
    entry: './src/index.js',
    output:{
        path: __dirname + "/public",
        filename:'bundle.js',
        publicPath: "/public/"
    },
    devServer: {
        inline: true,
        contentBase: './public',
        port: 3000
    },
    module:{
        rules: [
            {
            test: /\.js$/,
            exclude: /(node_modules)/,
            loader: "babel-loader",
            query: {
                presets: ['es2015', 'react', 'stage-0'],

            }
        }, 
        {
             test: /\.s(a|c)ss$/, 
                loader: ExtractTextPlugin.extract({loader: ['css-loader', 'sass-loader', 'style-loader']})
              },
              {
                test: /\.css$/,
                use: [
                  {
                    loader: 'style-loader',
                  },
                  {
                    loader: 'css-loader',
                  },
                ],
              },
              {
                test: /\.(|gif||svg|woff|woff2|eot|ttf)(\?v=[0-9]\.[0-9]\.[0-9])?$/, 
                loader: 'file-loader', options: {name: '[name].[ext]'}
              },  {
                test: /\.(png|jpg|)$/,
                loader: 'url-loader?limit=200000'
              },
        ] 
    },
    plugins: [
        new ExtractTextPlugin("styles.css"),
      ]

}

我正在使用 "webpack": "^2.7.0","@blueprintjs/core": "^1.34.1"和很多加载器

我试着像这样导入我的 css

require('!css-loader!./index.css');

就这样

import styles from './index.css'

结果是一样的

经过几个小时的额外工作,我得到了这个错误

enter image description here 在这一点上,我不确定我的 webpack 有什么问题以及如何修复它 欢迎任何建议

最佳答案

您可以将您的 webpack 配置与 Blueprint monorepo 中的配置进行比较:https://github.com/palantir/blueprint/tree/develop/packages/webpack-build-scripts

尝试以与基本配置相同的顺序应用加载器:['style-loader', 'css-loader', 'sass-loader']

关于css - webpack 2.7 不会加载 blueprintjs 核心 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47742198/

相关文章:

webpack-2 - 谷歌字体+ Webpack

javascript - 在固定在顶部之前,如何使粘性导航栏在英雄底部显示透明?

php - 在层次结构中首先显示 Div

javascript - 如果我需要在 React 组件之后设置 State,如何对服务器的失败响应使用react?

javascript - SwiperJS - 你如何设计分页项目符号?

javascript - 不断出现受控与非受控 react 错误

css - 为什么 z-index :99999999999; Disables inline style definition?

javascript - 无法让 CSS3 转换在 IE 10/11 中工作

html - Webpack:加载 *.eot 字体时出现 "OTS parsing error: invalid version tag"

reactjs - react-router-dom,有 `getComponent`的代码分割方法吗?