Skip to content

Commit

Permalink
Add importSources to @compiled/webpack-loader (#1623)
Browse files Browse the repository at this point in the history
* Add importSources to @compiled/webpack-loader
  • Loading branch information
dddlr authored Feb 7, 2024
1 parent 6d09679 commit 8d48ca0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-spoons-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@compiled/webpack-loader': patch
---

Add `importSources` option to @compiled/webpack-loader
5 changes: 5 additions & 0 deletions packages/webpack-loader/src/compiled-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function getLoaderOptions(context: LoaderContext<CompiledLoaderOptions>) {
classNameCompressionMap = undefined,
extractStylesToDirectory = undefined,
resolver = undefined,
importSources = undefined,
}: CompiledLoaderOptions = typeof context.getOptions === 'undefined'
? // Webpack v4 flow
getOptions(context)
Expand Down Expand Up @@ -86,6 +87,9 @@ function getLoaderOptions(context: LoaderContext<CompiledLoaderOptions>) {
resolver: {
type: 'string',
},
importSources: {
type: 'array',
},
},
});

Expand All @@ -105,6 +109,7 @@ function getLoaderOptions(context: LoaderContext<CompiledLoaderOptions>) {
classNameCompressionMap,
extractStylesToDirectory,
resolver,
importSources,
};
}

Expand Down
21 changes: 14 additions & 7 deletions packages/webpack-loader/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface CompiledLoaderOptions {
parserBabelPlugins?: ParserPlugin[];

/**
* Set to true if CompiledExtractPlugin has been set up correctly
* Set to true if CompiledExtractPlugin has been set up correctly.
*/
[pluginName]?: boolean;

Expand All @@ -73,29 +73,36 @@ export interface CompiledLoaderOptions {
ssr?: boolean;

/**
* Add the component name as class name to DOM in non-production environment if styled is used
* Add the component name as class name to DOM in non-production environment if styled is used.
*
* Default to `false`
* Defaults to `false`.
*/
addComponentName?: boolean;

/**
* A map holds the key-value pairs between full Atomic class names and the compressed ones
* i.e. { '_aaaabbbb': 'a' }
* A map holds the key-value pairs between full Atomic class names and the compressed ones,
* i.e. { '_aaaabbbb': 'a' }.
*
* Default to `undefined`
*/
classNameCompressionMap?: object;

/**
* When set, extract styles to an external CSS file
* When set, extract styles to an external CSS file.
*/
extractStylesToDirectory?: { source: string; dest: string };

/**
* Custom resolver for babel plugin, when set overrides default resolver
* Custom resolver for babel plugin, when set overrides default resolver.
*/
resolver?: string;

/**
* Custom module origins that Compiled should compile when using APIs from.
*
* Passed to @compiled/babel-plugin.
*/
importSources?: string[];
}

export interface CompiledExtractPluginOptions {
Expand Down

0 comments on commit 8d48ca0

Please sign in to comment.