Skip to content

Commit

Permalink
fix: style resources duplicates patterns (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
exreplay committed Oct 29, 2020
1 parent 61f36a4 commit 5b023bb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/@averjs/renderer/lib/utils/style-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PostCSS from './postcss';
import PerformanceLoader from './perf-loader';
import { AverConfig } from '@averjs/config';
import { Rule } from 'webpack-chain';
import { StyleResourcesLoaderOptions } from 'style-resources-loader';

export default class StyleLoader {
isProd = process.env.NODE_ENV === 'production';
Expand Down Expand Up @@ -83,19 +84,22 @@ export default class StyleLoader {
styleResources(rule: Rule<Rule>) {
if(!this.config.css?.styleResources) return;

const { resources, options = { patterns: [] } } = this.config.css.styleResources;
if (resources?.length === 0 || this.name === 'css') return;
const { resources = [], options = { patterns: [] } } = this.config.css.styleResources;
const finalOptions: StyleResourcesLoaderOptions = { patterns: [] };
if (this.name === 'css') return;

const patterns = map(resources, resource => path.resolve(process.cwd(), resource));
options.patterns = [
finalOptions.patterns = [
...options.patterns as string[],
...patterns
]

console.log(finalOptions);

rule
.use('style-resources-loader')
.loader('style-resources-loader')
.options(options);
.options(finalOptions);
}

css(rule: Rule<Rule>) {
Expand Down

0 comments on commit 5b023bb

Please sign in to comment.