Skip to content

Commit

Permalink
fix(plugins): fix file loader behavior (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVandivier authored Feb 16, 2023
1 parent b7f247a commit dcdd918
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions cli/config/plugin.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ module.exports = ({ env: webpackEnv, config, paths }) => {
chunkFilename: isProduction
? 'static/js/plugin-[name].[contenthash:8].chunk.js'
: 'static/js/plugin-[name].chunk.js',
// ! dhis2: this at least gets fonts to match the CRA build,
// but is re-outputting them
assetModuleFilename: 'static/media/[name].[hash][ext]',
// TODO: investigate dev source maps here (devtoolModuleFilenameTemplate)
},
optimization: {
Expand Down Expand Up @@ -275,33 +272,25 @@ module.exports = ({ env: webpackEnv, config, paths }) => {
},
}),
},
// dhis2: 'asset/resource' fixes fonts, but 'file-loader' breaks css modules
// when used for all asset types. So use each for respective files
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
generator: {
filename: 'static/media/[name].[hash][ext]',
},
},
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// In production, they would get copied to the `build` folder.
// This loader doesn't use a "test" so it will catch all modules
// that fall through the other loaders.
{
loader: require.resolve('file-loader'),
// Exclude `js` files to keep "css" loader working as it injects
// its runtime that would otherwise be processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
// by webpack's internal loaders.
exclude: [
/^$/,
/\.(js|mjs|jsx|ts|tsx)$/,
/\.html$/,
/\.json$/,
],
options: {
name: 'static/media/[name].[hash:8].[ext]',
type: 'asset/resource',
generator: {
filename: 'static/media/[name].[hash][ext]',
},
},
],
Expand Down

0 comments on commit dcdd918

Please sign in to comment.