From 3e99b3b5d6f8ce8526fa2385c49e02308587cba0 Mon Sep 17 00:00:00 2001 From: Swashata Ghosh Date: Mon, 28 Oct 2019 20:49:45 +0530 Subject: [PATCH] feat: export loaders from package for external usage --- packages/scripts/src/config/loaderHelpers.ts | 16 ++++++++++++++++ packages/scripts/src/index.ts | 8 ++++++++ 2 files changed, 24 insertions(+) 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