Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Bundling Options #14

Open
TheBigSasha opened this issue Sep 1, 2023 · 0 comments
Open

CSS Bundling Options #14

TheBigSasha opened this issue Sep 1, 2023 · 0 comments

Comments

@TheBigSasha
Copy link
Owner

Right now, we do not split css per module, because NextJS doesn't like to have style imports in components and the names of each stylesheet are not developer friendly.

Ideally, we'd like to simply import components only, and have them import their associated minified stylesheet build from every module stylesheet they import.

This works with the following in vue.config.ts

      libInjectCss({
        entry: {
          index: 'src/lib/index.ts', // Don't forget the main entry!
          ...scanEntries(['src/lib']),
        },
        rollupOptions: {
          output: {
            assetFileNames: 'assets/[hash][extname]',
          },
        },
      }),

However, this injects imports such as import '../../../assets/4gser621.css' in the components. This is great, but for NextJS it isn't good because stylesheet imports in components are unsupported.

If we continue with css splitting, we can indeed remove this and manually import these stylesheets in nextjs, but it would not be human friendly to import a separate stylesheet for each component, even with readable names.

Ideally, we'd build js files maintaining module imports, linking to minified import a from '[hash].module.css' files. This would work great in nextjs, but not work on targets not supporting css modules (who cares about them though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant