You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular 14 build fails when importing css in source code from node modules #23273
In the case of Fullcalendar they may be doing inside their own component and the following issue has been added their repo - fullcalendar/fullcalendar#6869
When running ng build you receive the following build error that look like the following -
./node_modules/@fullcalendar/common/main.css:4:0 - Error: Module parse failed: Unexpected token (4:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
🔬 Minimal Reproduction
🔥 Exception or Error
Error
./node_modules/@fullcalendar/common/main.css:4:0 - Error: Module parse failed: Unexpected token (4:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
./node_modules/froala-editor/css/plugins/table.css:7:0 - Error: Module parse failed: Unexpected token (7:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
This is expected and is one of the breaking changes in version 14 and pointed out in our release page.
We now issue a build time error when importing a CSS file as an ECMA module. This is non standard and Webpack specific feature and as such this feature was never supported by the Angular CLI.
If anyone else ends up here, for me the solution was that you can specify multiple scripts/styles bundles in the angular.json so we were able to create separate bundles that we can load when needed.
If anyone else ends up here, for me the solution was that you can specify multiple scripts/styles bundles in the angular.json so we were able to create separate bundles that we can load when needed.
If anyone else ends up here, for me the solution was that you can specify multiple scripts/styles bundles in the angular.json so we were able to create separate bundles that we can load when needed.
How do you deal with caching issues? Since the file is not hashed the browser will cache it. There are some workarounds here #12552 but since importing css throws now an error they wont work anymore
Thanks
How do you deal with caching issues? Since the file is not hashed the browser will cache it. There are some workarounds here #12552 but since importing css throws now an error they wont work anymore
Thanks
I don't have solution for that. If anyone has a solution for it, I'd be happy to hear. But går us, those files are changed so rarely that i think it's fine
How do you deal with caching issues? Since the file is not hashed the browser will cache it. There are some workarounds here #12552 but since importing css throws now an error they wont work anymore
Thanks
I don't have solution for that. If anyone has a solution for it, I'd be happy to hear. But går us, those files are changed so rarely that i think it's fine
@alan-agius4 I think it must be reopened because it is stable SASS functionality. When you compile static SASS files (specified in styles in angular.json) it has to work as documented.
It does work as documented unless there is a mistake, as such if you think it is incorrectly documented please provide a link where the docs are not correct.
Importing a Sass/CSS file inside your TypeScript/JavaScript file like an ECMA module is no not a standard functionality and as such this part is not supported.
Activity
alan-agius4 commentedon Jun 3, 2022
This is expected and is one of the breaking changes in version 14 and pointed out in our release page.
We now issue a build time error when importing a CSS file as an ECMA module. This is non standard and Webpack specific feature and as such this feature was never supported by the Angular CLI.
oBusk commentedon Jun 7, 2022
If anyone else ends up here, for me the solution was that you can specify multiple scripts/styles bundles in the
angular.jsonso we were able to create separate bundles that we can load when needed.Which will preprocess your style and output a
a-good-bundle-name.cssin your output. Ifinject: false, the name is not hashed.Hamarhu commentedon Jun 9, 2022
Thank you! This was helpfull!
salimchemes commentedon Jun 24, 2022
How do you deal with caching issues? Since the file is not hashed the browser will cache it. There are some workarounds here #12552 but since importing css throws now an error they wont work anymore
Thanks
oBusk commentedon Jun 24, 2022
I don't have solution for that. If anyone has a solution for it, I'd be happy to hear. But går us, those files are changed so rarely that i think it's fine
salimchemes commentedon Jun 30, 2022
I finally ended up adding a post build script to generate hashed files (with https://www.npmjs.com/package/hasha)
#12552 (comment)
Then added a validation to consume hashed file when is a production build. Otherwise use not hashed ones.
To summarize
delagen commentedon Jul 4, 2022
@alan-agius4 I think it must be reopened because it is stable SASS functionality. When you compile static SASS files (specified in styles in angular.json) it has to work as documented.
alan-agius4 commentedon Jul 4, 2022
It does work as documented unless there is a mistake, as such if you think it is incorrectly documented please provide a link where the docs are not correct.
Importing a Sass/CSS file inside your TypeScript/JavaScript file like an ECMA module is no not a standard functionality and as such this part is not supported.
delagen commentedon Jul 5, 2022
@alan-agius4 Yes. Sorry. Is is bug of @fullcalendar library
angular-automatic-lock-bot commentedon Aug 5, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.