Skip to content

Commit

Permalink
fix: should transpile all Vue SFC
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Nov 13, 2024
1 parent e0814dd commit 1da515e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { createRequire } from 'node:module';
import type { RsbuildPlugin, RspackChain } from '@rsbuild/core';
import type {
EnvironmentConfig,
RsbuildPlugin,
RspackChain,
} from '@rsbuild/core';
import { type VueLoaderOptions, VueLoaderPlugin } from 'vue-loader';
import { VueLoader15PitchFixPlugin } from './VueLoader15PitchFixPlugin.js';
import { applySplitChunksRule } from './splitChunks.js';
Expand Down Expand Up @@ -41,7 +45,7 @@ export function pluginVue2(options: PluginVueOptions = {}): RsbuildPlugin {
const VUE_REGEXP = /\.vue$/;
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;

api.modifyEnvironmentConfig((config) => {
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig }) => {
// Support `<style module>` in Vue SFC
if (config.output.cssModules.auto === true) {
config.output.cssModules.auto = (path, query) => {
Expand All @@ -54,7 +58,14 @@ export function pluginVue2(options: PluginVueOptions = {}): RsbuildPlugin {
};
}

return config;
const extraConfig: EnvironmentConfig = {
source: {
// should transpile all scripts from Vue SFC
include: [/\.vue/],
},
};

return mergeEnvironmentConfig(config, extraConfig);
});

api.modifyBundlerChain((chain, { CHAIN_ID }) => {
Expand Down

0 comments on commit 1da515e

Please sign in to comment.