Skip to content

Commit

Permalink
fix: filter rules
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 27, 2021
1 parent cd672f3 commit ccbd69e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
10 changes: 9 additions & 1 deletion examples/vue-cli/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ const ScriptSetup = require('unplugin-vue2-script-setup/webpack')
module.exports = {
configureWebpack: {
plugins: [
ScriptSetup(),
ScriptSetup({
refTransform: true,
}),
],
},
chainWebpack(config) {
// disable type check and let `vue-tsc` handles it
config.plugins.delete('fork-ts-checker')

// disable cache for testing, you should remove this in production
config.module.rule('vue').uses.delete('cache-loader')
config.module.rule('js').uses.delete('cache-loader')
config.module.rule('ts').uses.delete('cache-loader')
config.module.rule('tsx').uses.delete('cache-loader')
},
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export * from './core'

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

Expand Down
35 changes: 35 additions & 0 deletions test/__snapshots__/transform.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,41 @@ export default defineConfig({
"
`;
exports[`transform fixtures test/fixtures/A.vue 1`] = `
"<template>
<div @click=\\"counter\\">{{ msg }}: {{ count }}</div>
</template>
<script lang=\\"ts\\">
const __sfc_main = {
data() {
return {
msg: 'hello'
};
}
};
__sfc_main.setup = (__props, __ctx) => {
let count = 0;
function counter() {
count = count + 1;
}
return {
count,
counter
};
};
export default __sfc_main;
</script>
"
`;
exports[`transform fixtures test/fixtures/DynamicStyle.vue 1`] = `
"<template>
<div :style=\\"{ color, border: '1px' }\\" />
Expand Down

0 comments on commit ccbd69e

Please sign in to comment.