@rsbuild/plugin-vue 0.7.0-beta.3 → 0.7.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -81,8 +81,11 @@ function pluginVue(options = {}) {
81
81
  return {
82
82
  name: "rsbuild:vue",
83
83
  setup(api) {
84
+ const VUE_REGEXP = /\.vue$/;
85
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
84
86
  api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
85
- return mergeRsbuildConfig(config, {
87
+ var _a;
88
+ const extraConfig = {
86
89
  source: {
87
90
  define: {
88
91
  // https://link.vuejs.org/feature-flags
@@ -91,7 +94,19 @@ function pluginVue(options = {}) {
91
94
  __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
92
95
  }
93
96
  }
94
- });
97
+ };
98
+ const merged = mergeRsbuildConfig(extraConfig, config);
99
+ merged.output || (merged.output = {});
100
+ (_a = merged.output).cssModules || (_a.cssModules = {});
101
+ if (merged.output.cssModules.auto === true) {
102
+ merged.output.cssModules.auto = (path, query) => {
103
+ if (VUE_REGEXP.test(path)) {
104
+ return query.includes("type=style") && query.includes("module=true");
105
+ }
106
+ return CSS_MODULES_REGEX.test(path);
107
+ };
108
+ }
109
+ return merged;
95
110
  });
96
111
  api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
97
112
  chain.resolve.extensions.add(".vue");
@@ -104,7 +119,7 @@ function pluginVue(options = {}) {
104
119
  },
105
120
  options.vueLoaderOptions ?? {}
106
121
  );
107
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
122
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
108
123
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
109
124
  });
110
125
  applySplitChunksRule(api, options.splitChunks);
package/dist/index.js CHANGED
@@ -65,8 +65,11 @@ function pluginVue(options = {}) {
65
65
  return {
66
66
  name: "rsbuild:vue",
67
67
  setup(api) {
68
+ const VUE_REGEXP = /\.vue$/;
69
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
68
70
  api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
69
- return mergeRsbuildConfig(config, {
71
+ var _a;
72
+ const extraConfig = {
70
73
  source: {
71
74
  define: {
72
75
  // https://link.vuejs.org/feature-flags
@@ -75,7 +78,19 @@ function pluginVue(options = {}) {
75
78
  __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
76
79
  }
77
80
  }
78
- });
81
+ };
82
+ const merged = mergeRsbuildConfig(extraConfig, config);
83
+ merged.output || (merged.output = {});
84
+ (_a = merged.output).cssModules || (_a.cssModules = {});
85
+ if (merged.output.cssModules.auto === true) {
86
+ merged.output.cssModules.auto = (path2, query) => {
87
+ if (VUE_REGEXP.test(path2)) {
88
+ return query.includes("type=style") && query.includes("module=true");
89
+ }
90
+ return CSS_MODULES_REGEX.test(path2);
91
+ };
92
+ }
93
+ return merged;
79
94
  });
80
95
  api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
81
96
  chain.resolve.extensions.add(".vue");
@@ -88,7 +103,7 @@ function pluginVue(options = {}) {
88
103
  },
89
104
  options.vueLoaderOptions ?? {}
90
105
  );
91
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
106
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
92
107
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
93
108
  });
94
109
  applySplitChunksRule(api, options.splitChunks);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue",
3
- "version": "0.7.0-beta.3",
3
+ "version": "0.7.0-beta.5",
4
4
  "description": "Vue 3 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -25,17 +25,17 @@
25
25
  "dependencies": {
26
26
  "vue-loader": "^17.4.0",
27
27
  "webpack": "^5.91.0",
28
- "@rsbuild/shared": "0.7.0-beta.3"
28
+ "@rsbuild/shared": "0.7.0-beta.5"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.4.2",
32
32
  "vue": "^3.4.19",
33
33
  "webpack": "^5.91.0",
34
- "@rsbuild/core": "0.7.0-beta.3",
35
- "@scripts/test-helper": "0.7.0-beta.3"
34
+ "@rsbuild/core": "0.7.0-beta.5",
35
+ "@scripts/test-helper": "0.7.0-beta.5"
36
36
  },
37
37
  "peerDependencies": {
38
- "@rsbuild/core": "^0.7.0-beta.3"
38
+ "@rsbuild/core": "^0.7.0-beta.5"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public",