Commit a56d9a91 authored by Joe Haddad's avatar Joe Haddad Committed by JJ Kasper

Do Not Run File Loader on Server (#9843)

parent 6b50b132
...@@ -230,29 +230,31 @@ export const css = curry(async function css( ...@@ -230,29 +230,31 @@ export const css = curry(async function css(
}) })
) )
// Automatically transform references to files (i.e. url()) into URLs if (ctx.isClient) {
// e.g. url(./logo.svg) // Automatically transform references to files (i.e. url()) into URLs
fns.push( // e.g. url(./logo.svg)
loader({ fns.push(
oneOf: [ loader({
{ oneOf: [
// This should only be applied to CSS files {
issuer: { test: /\.css$/ }, // This should only be applied to CSS files
// Exclude extensions that webpack handles by default issuer: { test: /\.css$/ },
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/], // Exclude extensions that webpack handles by default
use: { exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
// `file-loader` always emits a URL reference, where `url-loader` use: {
// might inline the asset as a data URI // `file-loader` always emits a URL reference, where `url-loader`
loader: require.resolve('file-loader'), // might inline the asset as a data URI
options: { loader: require.resolve('file-loader'),
// Hash the file for immutable cacheability options: {
name: 'static/media/[name].[hash].[ext]', // Hash the file for immutable cacheability
name: 'static/media/[name].[hash].[ext]',
},
}, },
}, },
}, ],
], })
}) )
) }
const fn = pipe(...fns) const fn = pipe(...fns)
return fn(config) return fn(config)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment