Skip to content

Commit

Permalink
fix: only [jt]tx?, vue, not handle css
Browse files Browse the repository at this point in the history
  • Loading branch information
baozouai committed Jul 2, 2023
1 parent 44b143d commit 3b250cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
6 changes: 6 additions & 0 deletions playgrounds/vue/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ function onClick() {
</button>
</div>
</template>

<style>
button {
color: red;
}
</style>
30 changes: 15 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import traverse from '@babel/traverse'
import { parse } from '@babel/parser'
import generate from '@babel/generator'
import * as t from '@babel/types'
import type { FilterPattern, PluginOption } from 'vite'
import type { PluginOption } from 'vite'
import { createFilter } from 'vite'
import type { StringLiteral } from '@babel/types'

Expand Down Expand Up @@ -43,19 +43,19 @@ export interface Options {
splitBy?: string
// /** need endLine, default false */
// endLine?: boolean
/**
* Rules to include transforming target.
*
* @default [/\.[jt]sx?$/, /\.vue\??/]
*/
include?: FilterPattern
// /**
// * Rules to include transforming target.
// *
// * @default [/\.[jt]sx?$/, /\.vue$/]
// */
// include?: FilterPattern

/**
* Rules to exclude transforming target.
*
* @default [/node_modules/, /\.git/]
*/
exclude?: FilterPattern
// /**
// * Rules to exclude transforming target.
// *
// * @default [/node_modules/, /\.git/]
// */
// exclude?: FilterPattern
}

function generateStrNode(str: string): StringLiteral & { skip: boolean } {
Expand All @@ -80,8 +80,8 @@ export default function enhanceLogPlugin(options: Options = {}): PluginOption {
const splitNode = generateStrNode(splitBy)
let root = ''
const filter = createFilter(
options.include || [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/],
options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/],
[/\.[jt]sx?$/, /\.vue$/],
[/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/],
)
return {
name: 'enhance-log',
Expand Down

0 comments on commit 3b250cc

Please sign in to comment.