Hi,
I'm trying to use fylgja inside a new Symfony project, on my local machine running a Debian-based Linux distribution.
I've installed the Symfony bundle Encore that provides a Webpack configuration.
Here is my webpack.config.js
:
const Encore = require('@symfony/webpack-encore');
// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
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')
// only needed for CDN's or subdirectory deploy
//.setManifestKeyPrefix('build/')
/*
* ENTRY CONFIG
*
* Each entry will result in one JavaScript file (e.g. app.js)
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('app', './assets/app.js')
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge('./assets/controllers.json')
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
.splitEntryChunks()
// will require an extra script tag for runtime.js
// but, you probably want this, unless you're building a single-page app
.enableSingleRuntimeChunk()
/*
* FEATURE CONFIG
*
* Enable & configure other features below. For a full
* list of features, see:
* https://symfony.com/doc/current/frontend.html#adding-more-features
*/
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// configure Babel
// .configureBabel((config) => {
// config.plugins.push('@babel/a-babel-plugin');
// })
// enables and configure @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = '3.23';
})
// enables Sass/SCSS support
.enableSassLoader()
.enablePostCssLoader()
// uncomment if you use TypeScript
//.enableTypeScriptLoader()
// uncomment if you use React
//.enableReactPreset()
// uncomment to get integrity="..." attributes on your script & link tags
// requires WebpackEncoreBundle 1.4 or higher
//.enableIntegrityHashes(Encore.isProduction())
// uncomment if you're having problems with a jQuery plugin
//.autoProvidejQuery()
;
module.exports = Encore.getWebpackConfig();
Here is my package.json
:
{
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/preset-env": "^7.16.0",
"@hotwired/stimulus": "^3.0.0",
"@symfony/stimulus-bridge": "^3.2.0",
"@symfony/webpack-encore": "^4.0.0",
"core-js": "^3.23.0",
"postcss-loader": "^7.0.0",
"regenerator-runtime": "^0.13.9",
"sass": "^1.60.0",
"sass-loader": "^13.0.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-notifier": "^1.15.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
},
"dependencies": {
"@fylgja/mq": "^1.2.2",
"@fylgja/utilpack": "^1.2.1",
"fylgja": "^1.3.0"
}
}
And here is my app.scss
:
@use "@fylgja/theme" with ($color-theme: rebeccapurple,
$color-on-theme: white);
@use "@fylgja/base";
@use "@fylgja/details";
@use "@fylgja/table";
@use "@fylgja/list";
@use "@fylgja/breadcrumbs";
@use "@fylgja/pagination";
@use "@fylgja/avatar";
@use "@fylgja/button";
@use "@fylgja/container";
@use "@fylgja/section";
@use "@fylgja/card";
@use "@fylgja/hashlink";
@use "@fylgja/utilpack";
When I launch the encore dev-server
command, here is the output :
❯ yarn encore dev-server
yarn run v1.22.19
$ /home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/.bin/encore dev-server
Running webpack-dev-server ...
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/, http://[::1]:8080/
<i> [webpack-dev-server] Content not from webpack is served from '/home/bricebou/DEV/apprentissage/historiquetravaux/app/public' directory
<i> [webpack-dev-server] 404s will fallback to '/index.html'
ERROR Failed to compile with 2 errors 18:07:27
error in ./assets/styles/app.scss 18:07:27
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
6 │ @use "@fylgja/mq/helper" as mq;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
node_modules/@fylgja/utilpack/_helper.scss 6:1 @forward
node_modules/@fylgja/utilpack/_index.scss 4:1 @use
node_modules/@fylgja/utilpack/utilpack.scss 4:1 @use
assets/styles/app.scss 19:1 root stylesheet
error in ./assets/styles/app.scss 18:07:27
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
HookWebpackError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
6 │ @use "@fylgja/mq/helper" as mq;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
node_modules/@fylgja/utilpack/_helper.scss 6:1 @forward
node_modules/@fylgja/utilpack/_index.scss 4:1 @use
node_modules/@fylgja/utilpack/utilpack.scss 4:1 @use
assets/styles/app.scss 19:1 root stylesheet
at tryRunOrWebpackError (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/HookWebpackError.js:88:9)
at __webpack_require_module__ (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:5058:12)
at __webpack_require__ (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:5015:18)
at /home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:5086:20
at symbolIterator (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/neo-async/async.js:3485:9)
at done (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/neo-async/async.js:3527:9)
at Hook.eval [as callAsync] (eval at create (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
at /home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:4993:43
at symbolIterator (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/neo-async/async.js:3482:9)
at timesSync (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/neo-async/async.js:2297:7)
-- inner error --
Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
6 │ @use "@fylgja/mq/helper" as mq;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
node_modules/@fylgja/utilpack/_helper.scss 6:1 @forward
node_modules/@fylgja/utilpack/_index.scss 4:1 @use
node_modules/@fylgja/utilpack/utilpack.scss 4:1 @use
assets/styles/app.scss 19:1 root stylesheet
at Object.<anonymous> (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[1].use[1]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[1].use[2]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/resolve-url-loader/index.js??ruleSet[1].rules[4].oneOf[1].use[3]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[1].use[4]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/assets/styles/app.scss:1:7)
at /home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:441:11
at Hook.eval [as call] (eval at create (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
at /home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:5060:39
at tryRunOrWebpackError (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/HookWebpackError.js:83:7)
at __webpack_require_module__ (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:5058:12)
at __webpack_require__ (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:5015:18)
at /home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/webpack/lib/Compilation.js:5086:20
at symbolIterator (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/neo-async/async.js:3485:9)
at done (/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/neo-async/async.js:3527:9)
Generated code for /home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[1].use[1]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[1].use[2]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/resolve-url-loader/index.js??ruleSet[1].rules[4].oneOf[1].use[3]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[1].use[4]!/home/bricebou/DEV/apprentissage/historiquetravaux/app/assets/styles/app.scss
1 | throw new Error("Module build failed (from ./node_modules/sass-loader/dist/cjs.js):\nSassError: Can't find stylesheet to import.\n ╷\n6 │ @use \"@fylgja/mq/helper\" as mq;\n │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n ╵\n node_modules/@fylgja/utilpack/_helper.scss 6:1 @forward\n node_modules/@fylgja/utilpack/_index.scss 4:1 @use\n node_modules/@fylgja/utilpack/utilpack.scss 4:1 @use\n assets/styles/app.scss 19:1 root stylesheet");
Entrypoint app [big] 1.24 MiB = runtime.js 107 KiB vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_core-js_modules_es_da-514134.js 1.11 MiB app.js 28 KiB
webpack compiled with 2 errors
The issue is coming from the last use
statement within the SCSS:
The compilation works perfectly fine when removing this last line.
Any idea ?
Thanks a lot !