簡體   English   中英

Webpack Encore Zurb Foundation-sites 編譯錯誤

[英]Webpack Encore Zurb Foundation-sites compilation error

我正在嘗試在 Symfony 4 應用程序中使用 Foundation-sites 以及 Webpack Encore。 嘗試編譯 scss 文件時,出現以下錯誤:

./node_modules/.bin/encore dev
Running webpack ...

 ERROR  Failed to compile with 1 errors                                                                                                   6:42:54 AM

 error  in ./assets/css/app.css

CssSyntaxError

(10:3) Unclosed bracket

   8 |      for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
   9 |  }
> 10 | })(window, function(__WEBPACK_EXTERNAL_MODULE_jquery__) {
     |   ^
  11 | return /******/ (function(modules) { // webpackBootstrap
  12 | /******/     // The module cache
    at <anonymous>


 @ ./assets/js/app.js 9:0-24

我的配置如下:

webpack.config.js

var Encore = require('@symfony/webpack-encore');

if (!Encore.isRuntimeEnvironmentConfigured()) {
    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
    // directory where compiled assets will be stored
    .setOutputPath('public/build/')
    // public path used by the web server to access the output path
    .setPublicPath('/build')

    .addEntry('app', './assets/js/app.js')

    .splitEntryChunks()

    .enableSingleRuntimeChunk()

    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSourceMaps(!Encore.isProduction())
    // enables hashed filenames (e.g. app.abc123.css)
    .enableVersioning(Encore.isProduction())

    // enables @babel/preset-env polyfills
    .configureBabelPresetEnv((config) => {
        config.useBuiltIns = 'usage';
        config.corejs = 3;
    })

    // enables Sass/SCSS support
    .enableSassLoader(function (options) {
        options.sassOptions.includePaths = [
            '/vendor/zurb/foundation/scss'
        ];
        options.sassOptions.resolveUrlLoader= true;
    })


    .autoProvidejQuery()


;

module.exports = Encore.getWebpackConfig();

package.json

{
    "devDependencies": {
        "@symfony/webpack-encore": "^0.30.0",
        "core-js": "^3.0.0",
        "node-sass": "^4.14.1",
        "regenerator-runtime": "^0.13.2",
        "sass-loader": "^8.0.2",
        "sass": "^1.26.5",
        "webpack-notifier": "^1.6.0"
    },
    "license": "UNLICENSED",
    "private": true,
    "scripts": {
        "dev-server": "encore dev-server",
        "dev": "encore dev",
        "watch": "encore dev --watch",
        "build": "encore production --progress"
    },
    "dependencies": {
        "foundation-sites": "^6.6.3",
        "jquery": "^3.5.1"
    }
}

app.css

@import "~foundation-sites";

body {
    background-color: lightgray;
}

app.css 中的導入錯誤。

默認情況下它會導入 Js 並且錯誤提示“嘿,你不能將 js 代碼導入 css”。

所以正確的導入是:

 @import "~foundation-sites/dist/css/foundation.css";

或最小文件:

@import "~foundation-sites/dist/css/foundation.min.css";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM