From 4e561e5d9f6d581a4fe716b5f852defa76a4ac7b Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Tue, 26 Feb 2019 13:42:53 -0500 Subject: [PATCH] Resolve *-loader packages using `require.resolve` Fixes #305 --- packages/next-css/css-loader-config.js | 6 +++--- packages/next-less/index.js | 2 +- packages/next-sass/index.js | 2 +- packages/next-stylus/index.js | 2 +- packages/next-workers/index.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/next-css/css-loader-config.js b/packages/next-css/css-loader-config.js index 500086e1..919b776e 100644 --- a/packages/next-css/css-loader-config.js +++ b/packages/next-css/css-loader-config.js @@ -76,7 +76,7 @@ module.exports = ( ) postcssLoader = { - loader: 'postcss-loader', + loader: require.resolve('postcss-loader'), options: Object.assign({}, postcssLoaderOptions, { config: postcssOptionsConfig }) @@ -84,7 +84,7 @@ module.exports = ( } const cssLoader = { - loader: 'css-loader', + loader: require.resolve('css-loader'), options: Object.assign( {}, { @@ -99,7 +99,7 @@ module.exports = ( // When not using css modules we don't transpile on the server if (isServer && !cssLoader.options.modules) { - return ['ignore-loader'] + return [require.resolve('ignore-loader')] } // When on the server and using css modules we transpile the css diff --git a/packages/next-less/index.js b/packages/next-less/index.js index 1372f0f7..3ce7d29d 100644 --- a/packages/next-less/index.js +++ b/packages/next-less/index.js @@ -26,7 +26,7 @@ module.exports = (nextConfig = {}) => { isServer, loaders: [ { - loader: 'less-loader', + loader: require.resolve('less-loader'), options: lessLoaderOptions } ] diff --git a/packages/next-sass/index.js b/packages/next-sass/index.js index 3885e564..9a1bc7c3 100644 --- a/packages/next-sass/index.js +++ b/packages/next-sass/index.js @@ -26,7 +26,7 @@ module.exports = (nextConfig = {}) => { isServer, loaders: [ { - loader: 'sass-loader', + loader: require.resolve('sass-loader'), options: sassLoaderOptions } ] diff --git a/packages/next-stylus/index.js b/packages/next-stylus/index.js index 3da20201..f137116e 100644 --- a/packages/next-stylus/index.js +++ b/packages/next-stylus/index.js @@ -26,7 +26,7 @@ module.exports = (nextConfig = {}) => { isServer, loaders: [ { - loader: 'stylus-loader', + loader: require.resolve('stylus-loader'), options: stylusLoaderOptions } ] diff --git a/packages/next-workers/index.js b/packages/next-workers/index.js index 176d8932..dd3d67e7 100644 --- a/packages/next-workers/index.js +++ b/packages/next-workers/index.js @@ -9,7 +9,7 @@ module.exports = (nextConfig = {}) => { config.module.rules.push({ test: /\.worker\.js$/, - loader: 'worker-loader', + loader: require.resolve('worker-loader'), options: nextConfig.workerLoaderOptions || { name: 'static/[hash].worker.js', publicPath: '/_next/'