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

feat: skip normal css files without scoped flag in stylePostLoader #2053

Merged
merged 2 commits into from Oct 7, 2023

Conversation

Jinjiang
Copy link
Member

@Jinjiang Jinjiang commented Jul 7, 2023

So the loader vue-loader/dist/stylePostLoader.js can be used for pre-compiled Vue component files to handle scoped style imports.

e.g. in a Vue CLI project, you can just add these lines of code to make it work:

const { defineConfig } = require("@vue/cli-service");

module.exports = defineConfig({
  ...
  chainWebpack: (config) => {
    const ruleNameList = ["css", "scss", "sass", "less", "stylus"];
    ruleNameList.forEach((ruleName) => {
      const rule = config.module.rule(ruleName);
      rule
        .oneOf("normal")
        .use("style-post-loader")
        .loader("vue-loader/dist/stylePostLoader.js");
    });
    return config;
  },
});

...which would be great to be put into the default config of Vue CLI, despite it being out of maintenance.

Similar feature PR to Vite Plugin Vue: vitejs/vite-plugin-vue#196

@Jinjiang Jinjiang marked this pull request as ready for review October 4, 2023 03:05
@sodatea sodatea self-requested a review October 4, 2023 08:57
@sodatea sodatea merged commit 98782e7 into main Oct 7, 2023
6 checks passed
@sodatea sodatea deleted the standalone-style-post-loader branch October 7, 2023 06:57
@amagne1 amagne1 mentioned this pull request Oct 25, 2023
sodatea added a commit that referenced this pull request Oct 31, 2023
It is a side-effect of the style-post-loader that it adds a newline
after each CSS rule.
So now that style-post-loader isn't always skipped, the newlines must
be added back to the test expectations.
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

Successfully merging this pull request may close these issues.

None yet

2 participants