diff --git a/packages/scripts/src/config/loaderHelpers.ts b/packages/scripts/src/config/loaderHelpers.ts index f2af42db6..36b82b4d7 100644 --- a/packages/scripts/src/config/loaderHelpers.ts +++ b/packages/scripts/src/config/loaderHelpers.ts @@ -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'); diff --git a/packages/scripts/src/index.ts b/packages/scripts/src/index.ts index d67110868..e912882ca 100644 --- a/packages/scripts/src/index.ts +++ b/packages/scripts/src/index.ts @@ -46,6 +46,14 @@ export { issuerForStyleFiles, issuerForJsTsFiles, issuerForNonJsTsFiles, + getResolvedLoader, + babelLoader, + cssLoader, + fileLoader, + lessLoader, + getStyleLoaderUses, + postCssLoader, + sassLoader, } from './config/loaderHelpers'; // Expose all needed script classes