Skip to content

Commit

Permalink
fix: 多次执行时,loader 会添加多次
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Mar 12, 2021
1 parent d35a3db commit 657bb08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ export default class SanPhpLoaderPlugin {
runtimeHelperOutput: string;
outputPath: string;
sanSsrOptions: sanSsrOptions;
initialized: boolean;
constructor(options?: PluginOptions) {
this.runtimeHelperOutput = options?.runtimeHelper?.output || 'runtimeHelpers';
this.outputPath = options?.output?.path || '';
this.sanSsrOptions = options?.output || {};
this.initialized = false;
}
apply(compiler: Compiler) {

addStyleLoader(compiler);
addSanLoader(compiler);
if (!this.initialized) {
addStyleLoader(compiler);
addSanLoader(compiler);
this.initialized = true;
}

compiler.hooks.compilation.tap(id, compilation => {
styleStore.clear();
Expand Down

0 comments on commit 657bb08

Please sign in to comment.