symfony / webpack-encore

A simple but powerful API for processing & compiling assets built around Webpack
https://symfony.com/doc/current/frontend.html
MIT License
2.23k stars 199 forks source link

Sass loader fails with a particular additionalData #1353

Closed minimit closed 4 days ago

minimit commented 4 days ago

Hello I've a problem compiling with sass loader:

.enableSassLoader((options) => {
    options.additionalData = `$rootDir: ${rootDir};`;
})

When rootDir contains a point in the path, compiling gives this error:

[localhost]  ERROR  Failed to compile with 2 errors09:38:33
[localhost]  error  in ./node_modules/.pnpm/@sylius-ui+shop@file+vendor+sylius+sylius+src+Sylius+Bundle+ShopBundle_file-loader@6.2.0_webp_pjtk46n6pswykuwv5xdxwo7bxm/node_modules/@sylius-ui/shop/Resources/assets/styles/main.scss09:38:33
[localhost] Module build failed (from ./node_modules/.pnpm/sass-loader@16.0.3_sass@1.64.2_webpack@5.96.1_webpack-cli@5.1.4_/node_modules/sass-loader/dist/cjs.js):
[localhost] Expected digit.
[localhost]   ╷
[localhost] 1 │ $rootDir: /Users/user/Work/Websites/sylius-project/.build/releases/1;
[localhost]   │                                                        ^
[localhost]   ╵
[localhost]   node_modules/.pnpm/@sylius-ui+shop@file+vendor+sylius+sylius+src+Sylius+Bundle+ShopBundle_file-loader@6.2.0_webp_pjtk46n6pswykuwv5xdxwo7bxm/node_modules/@sylius-ui/shop/Resources/assets/styles/main.scss 1:56  root stylesheet
[localhost]  error  in ./node_modules/.pnpm/@sylius-ui+shop@file+vendor+sylius+sylius+src+Sylius+Bundle+ShopBundle_file-loader@6.2.0_webp_pjtk46n6pswykuwv5xdxwo7bxm/node_modules/@sylius-ui/shop/Resources/assets/styles/main.scss09:38:33
[localhost] Module build failed (from ./node_modules/.pnpm/mini-css-extract-plugin@2.9.2_webpack@5.96.1_webpack-cli@5.1.4_/node_modules/mini-css-extract-plugin/dist/loader.js):
[localhost] HookWebpackError: Module build failed (from ./node_modules/.pnpm/sass-loader@16.0.3_sass@1.64.2_webpack@5.96.1_webpack-cli@5.1.4_/node_modules/sass-loader/dist/cjs.js):
[localhost] Expected digit.
[localhost]   ╷
[localhost] 1 │ $rootDir: /Users/user/Work/Websites/sylius-project/.build/releases/1;
[localhost]   │                                                        ^
[localhost]   ╵
[localhost]   node_modules/.pnpm/@sylius-ui+shop@file+vendor+sylius+sylius+src+Sylius+Bundle+ShopBundle_file-loader@6.2.0_webp_pjtk46n6pswykuwv5xdxwo7bxm/node_modules/@sylius-ui/shop/Resources/assets/styles/main.scss 1:56  root stylesheet
stof commented 4 days ago

this does not seem related to webpack-encore at all. I suggest you to report this to the sass-loader project instead.

minimit commented 4 days ago

Yes tried with webpack sass loader and the problem persist, thanks I'll post on sass loader

Lyrkan commented 3 days ago

@minimit Maybe try adding quotes around the value:

options.additionalData = `$rootDir: '${rootDir}';`;
minimit commented 3 days ago

@minimit Maybe try adding quotes around the value:

options.additionalData = `$rootDir: '${rootDir}';`;

Yes seems to work like that thanks