Skip to content

Commit

Permalink
fix(plugin-utils): exclude config file from scanning by default
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 8, 2021
1 parent dc26236 commit 14a5a56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 103 deletions.
2 changes: 1 addition & 1 deletion examples/vue/windi.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'windicss/helpers'
export default defineConfig({
extract: {
include: ['**/*.{vue,html,jsx,tsx,ts}'],
exclude: ['node_modules', '.git', 'excluded', 'dist'],
exclude: ['node_modules', '.git', 'excluded', 'dist', 'windi.config.{ts,js}', 'tailwind.config.{ts,js}'],
},
darkMode: 'class',
safelist: 'select-none',
Expand Down
9 changes: 8 additions & 1 deletion packages/plugin-utils/src/resolveOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ export async function resolveOptions(
config.extract?.exclude,
scanOptions.exclude,
// only set default value when exclude is not provided
config.extract?.exclude ? [] : ['node_modules', '.git'],
config.extract?.exclude
? []
: [
'node_modules',
'.git',
'windi.config.{ts,js}',
'tailwind.config.{ts,js}',
],
)
.map(resolveGlob)

Expand Down
101 changes: 0 additions & 101 deletions test/__snapshots__/examples.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ Set {
"pl-100px",
"bg-yellow-200",
"mt-2",
"rounded",
"border",
"border-gray-300",
"text-gray-600",
"px-4",
"py-2",
"m-2",
"inline-block",
"hover:shadow",
}
`;

Expand Down Expand Up @@ -76,21 +67,6 @@ Set {
"vite-plugin-restart",
"excluded",
"included.css",
"windicss/helpers",
"vue,html,jsx,tsx,ts",
"node_modules",
".git",
"dist",
"class",
"rounded",
"border",
"border-gray-300",
"text-gray-600",
"px-4",
"py-2",
"m-2",
"inline-block",
"hover:shadow",
}
`;

Expand Down Expand Up @@ -145,15 +121,6 @@ Set {
"pl-100px",
"bg-yellow-200",
"mt-2",
"rounded",
"border",
"border-gray-300",
"text-gray-600",
"px-4",
"py-2",
"m-2",
"inline-block",
"hover:shadow",
}
`;

Expand Down Expand Up @@ -273,25 +240,9 @@ h2 {
--tw-bg-opacity: 1;
background-color: rgba(253, 230, 138, var(--tw-bg-opacity));
}
.border-gray-300 {
--tw-border-opacity: 1;
border-color: rgba(209, 213, 219, var(--tw-border-opacity));
}
.hover\\\\:rounded-full:hover {
border-radius: 9999px;
}
.rounded {
border-radius: 0.25rem;
}
.border {
border-width: 1px;
}
.inline-block {
display: inline-block;
}
.m-2 {
margin: 0.5rem;
}
.mt-2 {
margin-top: 0.5rem;
}
Expand All @@ -305,23 +256,9 @@ h2 {
padding-left: 1.25rem;
padding-right: 1.25rem;
}
.px-4 {
padding-left: 1rem;
padding-right: 1rem;
}
.py-2 {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.pl-100px {
padding-left: 100px;
}
.hover\\\\:shadow:hover {
--tw-shadow-color: 0, 0, 0;
--tw-shadow: 0 1px 3px 0 rgba(var(--tw-shadow-color), 0.1), 0 1px 2px 0 rgba(var(--tw-shadow-color), 0.06);
-webkit-box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.text-white {
--tw-text-opacity: 1;
color: rgba(255, 255, 255, var(--tw-text-opacity));
Expand All @@ -330,10 +267,6 @@ h2 {
--tw-text-opacity: 1;
color: rgba(209, 250, 229, var(--tw-text-opacity));
}
.text-gray-600 {
--tw-text-opacity: 1;
color: rgba(75, 85, 99, var(--tw-text-opacity));
}
.select-none {
-webkit-user-select: none;
-moz-user-select: none;
Expand Down Expand Up @@ -467,25 +400,9 @@ exports[`example should work: generated-css-utilities 1`] = `
--tw-bg-opacity: 1;
background-color: rgba(253, 230, 138, var(--tw-bg-opacity));
}
.border-gray-300 {
--tw-border-opacity: 1;
border-color: rgba(209, 213, 219, var(--tw-border-opacity));
}
.hover\\\\:rounded-full:hover {
border-radius: 9999px;
}
.rounded {
border-radius: 0.25rem;
}
.border {
border-width: 1px;
}
.inline-block {
display: inline-block;
}
.m-2 {
margin: 0.5rem;
}
.mt-2 {
margin-top: 0.5rem;
}
Expand All @@ -499,23 +416,9 @@ exports[`example should work: generated-css-utilities 1`] = `
padding-left: 1.25rem;
padding-right: 1.25rem;
}
.px-4 {
padding-left: 1rem;
padding-right: 1rem;
}
.py-2 {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.pl-100px {
padding-left: 100px;
}
.hover\\\\:shadow:hover {
--tw-shadow-color: 0, 0, 0;
--tw-shadow: 0 1px 3px 0 rgba(var(--tw-shadow-color), 0.1), 0 1px 2px 0 rgba(var(--tw-shadow-color), 0.06);
-webkit-box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.text-white {
--tw-text-opacity: 1;
color: rgba(255, 255, 255, var(--tw-text-opacity));
Expand All @@ -524,10 +427,6 @@ exports[`example should work: generated-css-utilities 1`] = `
--tw-text-opacity: 1;
color: rgba(209, 250, 229, var(--tw-text-opacity));
}
.text-gray-600 {
--tw-text-opacity: 1;
color: rgba(75, 85, 99, var(--tw-text-opacity));
}
.select-none {
-webkit-user-select: none;
-moz-user-select: none;
Expand Down

0 comments on commit 14a5a56

Please sign in to comment.