Skip to content

Commit

Permalink
Add ability to specify options to style-loader and css-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-petrov committed May 26, 2021
1 parent 6b32fba commit c6e7896
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/ember-auto-import/ts/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface Options {
alias?: { [fromName: string]: string };
webpack?: Configuration;
publicAssetURL?: string;
styleLoaderOptions?: Record<string, unknown>;
cssLoaderOptions?: Record<string, unknown>;
forbidEval?: boolean;
skipBabel?: { package: string; semverRange?: string }[];
watchDependencies?: (string | string[])[];
Expand Down Expand Up @@ -354,6 +356,16 @@ export default class Package {
return url;
}

get styleLoaderOptions(): Record<string, unknown> | undefined {
// only apps (not addons) are allowed to set this
return this.isAddon ? undefined : this.autoImportOptions?.styleLoaderOptions;
}

get cssLoaderOptions(): Record<string, unknown> | undefined {
// only apps (not addons) are allowed to set this
return this.isAddon ? undefined : this.autoImportOptions?.cssLoaderOptions;
}

get forbidsEval(): boolean {
// only apps (not addons) are allowed to set this, because it's motivated by
// the apps own Content Security Policy.
Expand Down
5 changes: 4 additions & 1 deletion packages/ember-auto-import/ts/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ export default class WebpackBundler extends Plugin implements Bundler {
this.babelRule(stagingDir),
{
test: /\.css$/i,
use: ['eai-style-loader', 'eai-css-loader'],
use: [
{ loader: 'eai-style-loader', options: [...this.opts.packages].find(pkg => pkg.styleLoaderOptions) },
{ loader: 'eai-css-loader', options: [...this.opts.packages].find(pkg => pkg.cssLoaderOptions) },
],
},
],
},
Expand Down

0 comments on commit c6e7896

Please sign in to comment.