Skip to content

Commit

Permalink
Merge pull request #408 from boris-petrov/style-and-css-loader-options
Browse files Browse the repository at this point in the history
Add ability to specify options to `style-loader` and `css-loader`
  • Loading branch information
ef4 authored Jun 16, 2021
2 parents 18ce3df + 9d60d87 commit 2bf7100
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 2bf7100

Please sign in to comment.