@rsbuild/plugin-vue 0.7.0-beta.4 → 0.7.0-beta.6

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
@@ -33,7 +33,6 @@ __export(src_exports, {
33
33
  pluginVue: () => pluginVue
34
34
  });
35
35
  module.exports = __toCommonJS(src_exports);
36
- var import_shared2 = require("@rsbuild/shared");
37
36
  var import_vue_loader = require("vue-loader");
38
37
 
39
38
  // src/splitChunks.ts
@@ -81,8 +80,11 @@ function pluginVue(options = {}) {
81
80
  return {
82
81
  name: "rsbuild:vue",
83
82
  setup(api) {
83
+ const VUE_REGEXP = /\.vue$/;
84
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
84
85
  api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
85
- return mergeRsbuildConfig(config, {
86
+ var _a;
87
+ const extraConfig = {
86
88
  source: {
87
89
  define: {
88
90
  // https://link.vuejs.org/feature-flags
@@ -91,20 +93,33 @@ function pluginVue(options = {}) {
91
93
  __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
92
94
  }
93
95
  }
94
- });
96
+ };
97
+ const merged = mergeRsbuildConfig(extraConfig, config);
98
+ merged.output || (merged.output = {});
99
+ (_a = merged.output).cssModules || (_a.cssModules = {});
100
+ if (merged.output.cssModules.auto === true) {
101
+ merged.output.cssModules.auto = (path, query) => {
102
+ if (VUE_REGEXP.test(path)) {
103
+ return query.includes("type=style") && query.includes("module=true");
104
+ }
105
+ return CSS_MODULES_REGEX.test(path);
106
+ };
107
+ }
108
+ return merged;
95
109
  });
96
110
  api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
97
111
  chain.resolve.extensions.add(".vue");
98
- const vueLoaderOptions = (0, import_shared2.deepmerge)(
99
- {
100
- compilerOptions: {
101
- preserveWhitespace: false
102
- },
103
- experimentalInlineMatchResource: true
104
- },
105
- options.vueLoaderOptions ?? {}
106
- );
107
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
112
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
113
+ const compilerOptions = {
114
+ preserveWhitespace: false,
115
+ ...userLoaderOptions.compilerOptions
116
+ };
117
+ const vueLoaderOptions = {
118
+ experimentalInlineMatchResource: true,
119
+ ...userLoaderOptions,
120
+ compilerOptions
121
+ };
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
@@ -14,14 +14,10 @@ import { fileURLToPath } from "url";
14
14
  import path from "path";
15
15
 
16
16
  // src/index.ts
17
- import { deepmerge } from "@rsbuild/shared";
18
17
  import { VueLoaderPlugin } from "vue-loader";
19
18
 
20
19
  // src/splitChunks.ts
21
- import {
22
- createCacheGroups,
23
- isPlainObject
24
- } from "@rsbuild/shared";
20
+ import { createCacheGroups, isPlainObject } from "@rsbuild/shared";
25
21
  var applySplitChunksRule = (api, options = {
26
22
  vue: true,
27
23
  router: true
@@ -65,8 +61,11 @@ function pluginVue(options = {}) {
65
61
  return {
66
62
  name: "rsbuild:vue",
67
63
  setup(api) {
64
+ const VUE_REGEXP = /\.vue$/;
65
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
68
66
  api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
69
- return mergeRsbuildConfig(config, {
67
+ var _a;
68
+ const extraConfig = {
70
69
  source: {
71
70
  define: {
72
71
  // https://link.vuejs.org/feature-flags
@@ -75,20 +74,33 @@ function pluginVue(options = {}) {
75
74
  __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
76
75
  }
77
76
  }
78
- });
77
+ };
78
+ const merged = mergeRsbuildConfig(extraConfig, config);
79
+ merged.output || (merged.output = {});
80
+ (_a = merged.output).cssModules || (_a.cssModules = {});
81
+ if (merged.output.cssModules.auto === true) {
82
+ merged.output.cssModules.auto = (path2, query) => {
83
+ if (VUE_REGEXP.test(path2)) {
84
+ return query.includes("type=style") && query.includes("module=true");
85
+ }
86
+ return CSS_MODULES_REGEX.test(path2);
87
+ };
88
+ }
89
+ return merged;
79
90
  });
80
91
  api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
81
92
  chain.resolve.extensions.add(".vue");
82
- const vueLoaderOptions = deepmerge(
83
- {
84
- compilerOptions: {
85
- preserveWhitespace: false
86
- },
87
- experimentalInlineMatchResource: true
88
- },
89
- options.vueLoaderOptions ?? {}
90
- );
91
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
93
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
94
+ const compilerOptions = {
95
+ preserveWhitespace: false,
96
+ ...userLoaderOptions.compilerOptions
97
+ };
98
+ const vueLoaderOptions = {
99
+ experimentalInlineMatchResource: true,
100
+ ...userLoaderOptions,
101
+ compilerOptions
102
+ };
103
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
92
104
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
93
105
  });
94
106
  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.4",
3
+ "version": "0.7.0-beta.6",
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.4"
28
+ "@rsbuild/shared": "0.7.0-beta.6"
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.4",
35
- "@scripts/test-helper": "0.7.0-beta.4"
34
+ "@rsbuild/core": "0.7.0-beta.6",
35
+ "@scripts/test-helper": "0.7.0-beta.6"
36
36
  },
37
37
  "peerDependencies": {
38
- "@rsbuild/core": "^0.7.0-beta.4"
38
+ "@rsbuild/core": "^0.7.0-beta.6"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public",