Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit ccbd69e

Browse files
committed
fix: filter rules
1 parent cd672f3 commit ccbd69e

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

examples/vue-cli/vue.config.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ const ScriptSetup = require('unplugin-vue2-script-setup/webpack')
88
module.exports = {
99
configureWebpack: {
1010
plugins: [
11-
ScriptSetup(),
11+
ScriptSetup({
12+
refTransform: true,
13+
}),
1214
],
1315
},
1416
chainWebpack(config) {
1517
// disable type check and let `vue-tsc` handles it
1618
config.plugins.delete('fork-ts-checker')
19+
20+
// disable cache for testing, you should remove this in production
21+
config.module.rule('vue').uses.delete('cache-loader')
22+
config.module.rule('js').uses.delete('cache-loader')
23+
config.module.rule('ts').uses.delete('cache-loader')
24+
config.module.rule('tsx').uses.delete('cache-loader')
1725
},
1826
}

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export * from './core'
77

88
export default createUnplugin<PluginOptions>((options = {}) => {
99
const filter = createFilter(
10-
options.include || options.refTransform ? [/\.vue$/] : [/\.vue$/, /\.[jt]sx?$/],
10+
options.include || (options.refTransform ? [/\.vue$/, /\.vue\?vue/, /\.[jt]sx?$/] : [/\.vue$/, /\.vue\?vue/]),
1111
options.exclude || [/node_modules/, /\.git/, /\.nuxt/],
1212
)
1313

test/__snapshots__/transform.test.ts.snap

+35
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,41 @@ export default defineConfig({
145145
"
146146
`;
147147
148+
exports[`transform fixtures test/fixtures/A.vue 1`] = `
149+
"<template>
150+
<div @click=\\"counter\\">{{ msg }}: {{ count }}</div>
151+
</template>
152+
153+
<script lang=\\"ts\\">
154+
const __sfc_main = {
155+
data() {
156+
return {
157+
msg: 'hello'
158+
};
159+
}
160+
161+
};
162+
163+
__sfc_main.setup = (__props, __ctx) => {
164+
let count = 0;
165+
166+
function counter() {
167+
count = count + 1;
168+
}
169+
170+
return {
171+
count,
172+
counter
173+
};
174+
};
175+
176+
export default __sfc_main;
177+
</script>
178+
179+
180+
"
181+
`;
182+
148183
exports[`transform fixtures test/fixtures/DynamicStyle.vue 1`] = `
149184
"<template>
150185
<div :style=\\"{ color, border: '1px' }\\" />

0 commit comments

Comments
 (0)