在将Webpack更新到4.35.3和将Laravel Mix更新到4.1.2之后,模块构建失败

时间:2019-07-09 08:26:26

标签: webpack laravel-mix

嗨,我已经使用Webpack 4.35.2和Laravel Mix 4.0.16了很长时间。今天,我将它们更新到最新版本(Webpack 4.35.3,Laravel Mix 4.1.2),并且我的项目无法构建。这是错误:

"Module build failed (from ./node_modules/css-loader/dist/cjs.js):

ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):
// Fonts
^
      Invalid CSS after "": expected 1 selector or at-rule, was "var content = requi"
      in /resources/assets/sass/app.scss (line 1, column 1)
    "
ERROR in ./resources/assets/sass/app.scss
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):

@import url("https://fonts.googleapis.com/css?family=Ubuntu:300,400,600");
^
      Invalid CSS after "": expected 1 selector or at-rule, was "var content = requi"
      in /resources/assets/sass/app.scss (line 1, column 1)

这是我的 webpack.mix.js

const  mix  = require('laravel-mix');

mix.sass('resources/assets/sass/app.scss', 'public/css/app.css')
    .react([
        'resources/js/app.js'
    ], 'public/js/app.js')

mix.sourceMaps().webpackConfig({devtool: 'source-map'});
mix.webpackConfig({
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
      },
      {
        test: /\.jsx$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        use: ['style-loader', 'css-loader', 'sass-loader']
      },
      {
        test: /\.(png|jpg)$/,
        exclude: /node_modules/,
        loader: 'file-loader'
      },
    ]
  },
});

mix.extract();

我的app.scss:

// Fonts
@import url("https://fonts.googleapis.com/css?family=Ubuntu:300,400,600");

@import "variables";
@import "../../../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
@import "../../../../node_modules/font-awesome/scss/font-awesome";

@import "mixins";
...

有趣的是,如果我评论导入Google字体,则错误将指向@import“变量”;

0 个答案:

没有答案