Skip to content

Commit 346fd9a

Browse files
harwinvoidyanghuayun
andauthored
feat: add test option (#1)
* feat: add test option * feat: remove default assignment in constructor Co-authored-by: yanghuayun <yanghuayun@gumingnc.com>
1 parent 4607927 commit 346fd9a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface IMinifyPluginOpts extends AllowTransformOpts {
2323
include?: Filter | Filter[]
2424
exclude?: Filter | Filter[]
2525
targets?: string | string[]
26+
test?: RegExp
2627
implementation?: Implementation
2728
}
2829

src/minify.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ export class ParcelCssMinifyPlugin {
2424
private readonly transform: TransformType
2525

2626
constructor(opts: IMinifyPluginOpts = {}) {
27-
const { implementation, ...otherOpts } = opts
27+
const { implementation, ...otherOpts } = opts
2828
if (implementation && typeof implementation.transform !== 'function') {
2929
throw new TypeError(
3030
`[ParcelCssMinifyPlugin]: implementation.transform must be an '@parcel/css' transform function. Received ${typeof implementation.transform}`
3131
)
3232
}
3333

3434
this.transform = implementation?.transform ?? _transform
35-
this.options = otherOpts
35+
this.options = {
36+
...otherOpts
37+
}
3638
}
3739

3840
apply(compiler: Compiler) {
@@ -88,6 +90,7 @@ export class ParcelCssMinifyPlugin {
8890
const {
8991
include,
9092
exclude,
93+
test: testRegExp,
9194
targets: userTargets,
9295
...transformOptions
9396
} = this.options
@@ -97,7 +100,7 @@ export class ParcelCssMinifyPlugin {
97100
// Filter out already minimized
98101
!asset.info.minimized &&
99102
// Filter out by file type
100-
CSS_FILE_REG.test(asset.name) &&
103+
(testRegExp || CSS_FILE_REG).test(asset.name) &&
101104
matchObject({ include, exclude }, asset.name)
102105
)
103106

0 commit comments

Comments
 (0)