@rsbuild/plugin-vue2 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
@@ -38,7 +38,6 @@ __export(src_exports, {
38
38
  pluginVue2: () => pluginVue2
39
39
  });
40
40
  module.exports = __toCommonJS(src_exports);
41
- var import_shared2 = require("@rsbuild/shared");
42
41
  var import_vue_loader = require("vue-loader");
43
42
 
44
43
  // src/VueLoader15PitchFixPlugin.ts
@@ -121,21 +120,38 @@ function pluginVue2(options = {}) {
121
120
  return {
122
121
  name: "rsbuild:vue2",
123
122
  setup(api) {
123
+ const VUE_REGEXP = /\.vue$/;
124
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
125
+ api.modifyRsbuildConfig((config) => {
126
+ var _a;
127
+ config.output || (config.output = {});
128
+ (_a = config.output).cssModules || (_a.cssModules = {});
129
+ if (config.output.cssModules.auto === true) {
130
+ config.output.cssModules.auto = (path, query) => {
131
+ if (VUE_REGEXP.test(path)) {
132
+ return query.includes("type=style") && query.includes("module=true");
133
+ }
134
+ return CSS_MODULES_REGEX.test(path);
135
+ };
136
+ }
137
+ return config;
138
+ });
124
139
  api.modifyBundlerChain((chain, { CHAIN_ID }) => {
125
140
  chain.resolve.extensions.add(".vue");
126
141
  if (!chain.resolve.alias.get("vue$")) {
127
142
  chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
128
143
  }
129
- const vueLoaderOptions = (0, import_shared2.deepmerge)(
130
- {
131
- compilerOptions: {
132
- preserveWhitespace: false
133
- },
134
- experimentalInlineMatchResource: true
135
- },
136
- options.vueLoaderOptions ?? {}
137
- );
138
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
144
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
145
+ const compilerOptions = {
146
+ preserveWhitespace: false,
147
+ ...userLoaderOptions.compilerOptions
148
+ };
149
+ const vueLoaderOptions = {
150
+ experimentalInlineMatchResource: true,
151
+ ...userLoaderOptions,
152
+ compilerOptions
153
+ };
154
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(require.resolve("vue-loader")).options(vueLoaderOptions);
139
155
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(import_vue_loader.VueLoaderPlugin);
140
156
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
141
157
  });
package/dist/index.js CHANGED
@@ -20,7 +20,6 @@ import { fileURLToPath } from "url";
20
20
  import path from "path";
21
21
 
22
22
  // src/index.ts
23
- import { deepmerge } from "@rsbuild/shared";
24
23
  import { VueLoaderPlugin } from "vue-loader";
25
24
 
26
25
  // src/VueLoader15PitchFixPlugin.ts
@@ -63,10 +62,7 @@ var VueLoader15PitchFixPlugin = class {
63
62
  };
64
63
 
65
64
  // src/splitChunks.ts
66
- import {
67
- createCacheGroups,
68
- isPlainObject
69
- } from "@rsbuild/shared";
65
+ import { createCacheGroups, isPlainObject } from "@rsbuild/shared";
70
66
  var applySplitChunksRule = (api, options = {
71
67
  vue: true,
72
68
  router: true
@@ -106,21 +102,38 @@ function pluginVue2(options = {}) {
106
102
  return {
107
103
  name: "rsbuild:vue2",
108
104
  setup(api) {
105
+ const VUE_REGEXP = /\.vue$/;
106
+ const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
107
+ api.modifyRsbuildConfig((config) => {
108
+ var _a;
109
+ config.output || (config.output = {});
110
+ (_a = config.output).cssModules || (_a.cssModules = {});
111
+ if (config.output.cssModules.auto === true) {
112
+ config.output.cssModules.auto = (path2, query) => {
113
+ if (VUE_REGEXP.test(path2)) {
114
+ return query.includes("type=style") && query.includes("module=true");
115
+ }
116
+ return CSS_MODULES_REGEX.test(path2);
117
+ };
118
+ }
119
+ return config;
120
+ });
109
121
  api.modifyBundlerChain((chain, { CHAIN_ID }) => {
110
122
  chain.resolve.extensions.add(".vue");
111
123
  if (!chain.resolve.alias.get("vue$")) {
112
124
  chain.resolve.alias.set("vue$", "vue/dist/vue.runtime.esm.js");
113
125
  }
114
- const vueLoaderOptions = deepmerge(
115
- {
116
- compilerOptions: {
117
- preserveWhitespace: false
118
- },
119
- experimentalInlineMatchResource: true
120
- },
121
- options.vueLoaderOptions ?? {}
122
- );
123
- chain.module.rule(CHAIN_ID.RULE.VUE).test(/\.vue$/).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
126
+ const userLoaderOptions = options.vueLoaderOptions ?? {};
127
+ const compilerOptions = {
128
+ preserveWhitespace: false,
129
+ ...userLoaderOptions.compilerOptions
130
+ };
131
+ const vueLoaderOptions = {
132
+ experimentalInlineMatchResource: true,
133
+ ...userLoaderOptions,
134
+ compilerOptions
135
+ };
136
+ chain.module.rule(CHAIN_ID.RULE.VUE).test(VUE_REGEXP).use(CHAIN_ID.USE.VUE).loader(__require.resolve("vue-loader")).options(vueLoaderOptions);
124
137
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_PLUGIN).use(VueLoaderPlugin);
125
138
  chain.plugin(CHAIN_ID.PLUGIN.VUE_LOADER_15_PITCH_FIX_PLUGIN).use(VueLoader15PitchFixPlugin);
126
139
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-vue2",
3
- "version": "0.7.0-beta.4",
3
+ "version": "0.7.0-beta.6",
4
4
  "description": "Vue 2 plugin of Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -25,16 +25,16 @@
25
25
  "dependencies": {
26
26
  "vue-loader": "^15.11.1",
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
  "webpack": "^5.91.0",
33
- "@rsbuild/core": "0.7.0-beta.4",
34
- "@scripts/test-helper": "0.7.0-beta.4"
33
+ "@rsbuild/core": "0.7.0-beta.6",
34
+ "@scripts/test-helper": "0.7.0-beta.6"
35
35
  },
36
36
  "peerDependencies": {
37
- "@rsbuild/core": "^0.7.0-beta.4"
37
+ "@rsbuild/core": "^0.7.0-beta.6"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",