Skip to content

Commit

Permalink
feat: export loaders from package for external usage
Browse files Browse the repository at this point in the history
  • Loading branch information
swashata committed Oct 28, 2019
1 parent 31b15b2 commit 3e99b3b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/scripts/src/config/loaderHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,19 @@ export function getStyleLoaderUses(

return styleLoader;
}

/**
* Get resolved loader from @wpackio/scripts for your own usage.
*
* @param loader Webpack Loader.
*/
export function getResolvedLoader(loader: string) {
return require.resolve(loader);
}

export const babelLoader = getResolvedLoader('babel-loader');
export const fileLoader = getResolvedLoader('file-loader');
export const cssLoader = getResolvedLoader('css-loader');
export const sassLoader = getResolvedLoader('sass-loader');
export const lessLoader = getResolvedLoader('less-loader');
export const postCssLoader = getResolvedLoader('postcss-loader');
8 changes: 8 additions & 0 deletions packages/scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export {
issuerForStyleFiles,
issuerForJsTsFiles,
issuerForNonJsTsFiles,
getResolvedLoader,
babelLoader,
cssLoader,
fileLoader,
lessLoader,
getStyleLoaderUses,
postCssLoader,
sassLoader,
} from './config/loaderHelpers';

// Expose all needed script classes
Expand Down

0 comments on commit 3e99b3b

Please sign in to comment.