diff --git a/packages/next/build/webpack/config/blocks/css/index.ts b/packages/next/build/webpack/config/blocks/css/index.ts index 418b5c170bb46..f2334614cc355 100644 --- a/packages/next/build/webpack/config/blocks/css/index.ts +++ b/packages/next/build/webpack/config/blocks/css/index.ts @@ -283,7 +283,7 @@ export const css = curry(async function css( use: { // `file-loader` always emits a URL reference, where `url-loader` // might inline the asset as a data URI - loader: require.resolve('file-loader'), + loader: require.resolve('next/dist/compiled/file-loader'), options: { // Hash the file for immutable cacheability name: 'static/media/[name].[hash].[ext]', diff --git a/packages/next/package.json b/packages/next/package.json index d8308d7020f2c..cb27b60d52c1f 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -81,7 +81,6 @@ "browserslist": "4.8.3", "css-loader": "3.3.0", "cssnano-simple": "1.0.0", - "file-loader": "4.2.0", "fork-ts-checker-webpack-plugin": "3.1.1", "ignore-loader": "0.1.2", "jest-worker": "24.9.0", @@ -167,6 +166,7 @@ "dotenv-expand": "5.1.0", "escape-string-regexp": "2.0.0", "etag": "1.8.1", + "file-loader": "4.2.0", "finally-polyfill": "0.1.0", "find-up": "4.0.0", "fresh": "0.5.2", diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 1a82ee0b9e8b7..0832586e250d3 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -214,6 +214,14 @@ export async function ncc_etag(task, opts) { .target('dist/compiled/etag') } // eslint-disable-next-line camelcase +externals['file-loader'] = 'next/dist/compiled/file-loader' +export async function ncc_file_loader(task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('file-loader'))) + .ncc({ packageName: 'file-loader', externals }) + .target('dist/compiled/file-loader') +} +// eslint-disable-next-line camelcase externals['find-up'] = 'next/dist/compiled/find-up' export async function ncc_find_up(task, opts) { await task @@ -475,6 +483,7 @@ export async function precompile(task) { 'ncc_dotenv_expand', 'ncc_escape_string_regexp', 'ncc_etag', + 'ncc_file_loader', 'ncc_find_up', 'ncc_fresh', 'ncc_gzip_size',