-
Enjoying the concepts behind this plugin and the clarity it brings to the webpack set up and configuration. Quick question — there's a comment about using the hash to allow multiple chunks with the same names, but relying on the hash ( I'm working on a very large site with many components and many "index.scss" files due to how the components are built and styled. We currently use the following pattern to lazy import (I have a separate question about that) CSS files as various routes load: import /* webpackChunkName: "foo-styles" */ 'Foo/styles/index.scss'; You then get a chunk named that, irregardless of what your We can use the hash name of course, but it strikes me that magic-comments are part of the core webpack feature set and this plugin is breaking with that pattern. Is there any way to get that to work in the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hello @rcherny, can you please create a small repo with some dummy components and an example which filenames are expected. How it works in current versionThe plugin has the {
css: {
filename: '[name].css', // <= filename of CSS defined in link tag
chunkFilename: '[name].css', // <= filename of CSS imported in JS, the `name` is JS filename
},
} Both When no Note:all SCSS/CSS files imported in one JS will be joined into single output CSS file with the name of JS file where these styles was imported. E.g. import '@styles/common.scss'; // style from other dir, using webpack alias
import './index.scss'; // style from the local dir where is the JS The generated files:
|
Beta Was this translation helpful? Give feedback.
-
Here is additional info how it works with nested components. In a complex use case, when used many components importing others components (nested components), then all nested imported styles will be joined in one singe CSS file with the name of the root JS file. For example:
The import './style.scss'; // import CSS
import A from './component-a.js'; // import nested JS component containing owns styles The nested import './component-a1.scss'; // import nested CSS
import './component-a2.scss'; // import nested CSS All CSS content extracted from all nested (child) files will be saved into single file main.css (
Note: Split CSS chunks does't work and won't be implemented. Therefore the magic comment |
Beta Was this translation helpful? Give feedback.
-
Really appreciate all the follow up on this. I've had a super hectic week and I'm going on vacation this coming week; so I'll follow up more when I return. Thanks again! |
Beta Was this translation helpful? Give feedback.
@rcherny
Here is additional info how it works with nested components.
In a complex use case, when used many components importing others components (nested components), then all nested imported styles will be joined in one singe CSS file with the name of the root JS file.
For example:
The
entry point
(root JS file) ./main.jsThe nested
child
JS file ./component-a.js