【问题标题】:Bootstrap with webpack使用 webpack 引导
【发布时间】:2019-08-21 08:18:18
【问题描述】:

我正在尝试将 bootstrap-css-only 添加到 react-boilerplate 项目 但我得到错误。 如果我删除 @import 行,它可以正常工作

global-styles.scss

@import '~bootstrap-css-only/css/bootstrap';
@import 'assets/styles/Antd/antd.cleanui';
@import 'assets/styles/CleanUI/cleanui';
@import 'assets/styles/Bootstrap/bootstrap.cleanui';
@import 'assets/styles/Chartist/chartist.cleanui';
@import 'assets/styles/Nprogress/nprogress.cleanui';
@import 'assets/styles/Rcdrawer/rcdrawer.cleanui';
@import '~c3/c3.min.css';

webpack.base.js

module: {
    noParse: /moment\.js/,
    rules: [
      {
        test: /\.js$/, // Transform all .js files required somewhere with Babel
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          query: {
            plugins: [
              [
                'import',
                {
                  libraryName: 'antd',
                  style: 'css',
                },
              ],
            ],
          },
        },
      },
      {
        test: /\.(eot|otf|ttf|woff|woff2)$/,
        use: 'file-loader',
        exclude: /\.(less|scss|css)$/,
      },
      {
        test: /\.(less|scss|css)$/,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              importLoaders: 1,
            },
          },
          'less-loader',
          'sass-loader',
        ],
      },
      {
        test: /\.svg$/,
        use: [
          {
            loader: 'svg-url-loader',
            options: {
              // Inline files smaller than 10 kB
              limit: 10 * 1024,
              noquotes: true,
            },
          },
        ],
      },
      {
        test: /\.(jpg|png|gif)$/,
        use: [
          {
            loader: 'url-loader',
            options: {
              // Inline files smaller than 10 kB
              limit: 10 * 1024,
            },
          },
          {
            loader: 'image-webpack-loader',
            options: {
              mozjpeg: {
                enabled: false,
                // NOTE: mozjpeg is disabled as it causes errors in some Linux environments
                // Try enabling it in your environment by switching the config to:
                // enabled: true,
                // progressive: true,
              },
              gifsicle: {
                interlaced: false,
              },
              optipng: {
                optimizationLevel: 7,
              },
              pngquant: {
                quality: '65-90',
                speed: 4,
              },
            },
          },
        ],
      },
      {
        test: /\.html$/,
        use: 'html-loader',
      },
      {
        test: /\.(mp4|webm)$/,
        use: {
          loader: 'url-loader',
          options: {
            limit: 10000,
          },
        },
      },
    ],
  },

无法读取未定义的属性“分母” 在 C:\Recp\node_modules\bootstrap-css-only\css\bootstrap.min.css (第 6 行,第 26583 列)@ ./app/global-styles.scss (./node_modules/css-loader??ref--6-1!./node_modules/less-loader/dist/cjs.js!./node_modules/sass-lo ader/lib/loader.js!./app/global-styles.scss) 3:10-149 @ ./app/global-styles.scss @ ./app/app.js @ 多 ./node_modules/react-app-polyfill/ie11.js webpack-hot-middleware/client?reload=true ./app/app.js

【问题讨论】:

    标签: css reactjs webpack sass bootstrap-4


    【解决方案1】:

    删除 .css extebtion,scss 编译器将内联 css 文件。现在它正在尝试通过另一个请求加载文件。

    【讨论】:

      猜你喜欢
      • 2016-12-24
      • 2017-08-12
      • 2016-03-25
      • 1970-01-01
      • 2017-07-19
      • 2018-07-11
      • 2016-06-30
      • 2016-06-10
      • 1970-01-01
      相关资源
      最近更新 更多