Skip to content

Commit 2bf7100

Browse files
authored
Merge pull request #408 from boris-petrov/style-and-css-loader-options
Add ability to specify options to `style-loader` and `css-loader`
2 parents 18ce3df + 9d60d87 commit 2bf7100

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/ember-auto-import/ts/package.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface Options {
2929
alias?: { [fromName: string]: string };
3030
webpack?: Configuration;
3131
publicAssetURL?: string;
32+
styleLoaderOptions?: Record<string, unknown>;
33+
cssLoaderOptions?: Record<string, unknown>;
3234
forbidEval?: boolean;
3335
skipBabel?: { package: string; semverRange?: string }[];
3436
watchDependencies?: (string | string[])[];
@@ -354,6 +356,16 @@ export default class Package {
354356
return url;
355357
}
356358

359+
get styleLoaderOptions(): Record<string, unknown> | undefined {
360+
// only apps (not addons) are allowed to set this
361+
return this.isAddon ? undefined : this.autoImportOptions?.styleLoaderOptions;
362+
}
363+
364+
get cssLoaderOptions(): Record<string, unknown> | undefined {
365+
// only apps (not addons) are allowed to set this
366+
return this.isAddon ? undefined : this.autoImportOptions?.cssLoaderOptions;
367+
}
368+
357369
get forbidsEval(): boolean {
358370
// only apps (not addons) are allowed to set this, because it's motivated by
359371
// the apps own Content Security Policy.

packages/ember-auto-import/ts/webpack.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ export default class WebpackBundler extends Plugin implements Bundler {
188188
this.babelRule(stagingDir),
189189
{
190190
test: /\.css$/i,
191-
use: ['eai-style-loader', 'eai-css-loader'],
191+
use: [
192+
{ loader: 'eai-style-loader', options: [...this.opts.packages].find(pkg => pkg.styleLoaderOptions) },
193+
{ loader: 'eai-css-loader', options: [...this.opts.packages].find(pkg => pkg.cssLoaderOptions) },
194+
],
192195
},
193196
],
194197
},

0 commit comments

Comments
 (0)