1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-22 06:34:22 +00:00

Configure css-loader to output user-readable classNames

This commit is contained in:
Steffo 2022-06-11 01:58:18 +02:00
parent 7439139ae0
commit bbe4f33827
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -1,10 +1,67 @@
const {i18n} = require("./next-i18next.config")
const { i18n } = require("./next-i18next.config")
function fixCssLoaderLocalIdent(webpackConfig) {
function innerFix(used) {
if (used.loader?.match?.(/[/]css-loader/)) {
let modules = used.loader.options?.modules
if (modules) {
let { getLocalIdent, ...modules } = modules
modules.localIdentName = "[name]-[local]"
used.loader.options.modules = modules
}
}
return used
}
webpackConfig.module.rules = webpackConfig.module.rules.map(rule => {
if (rule.oneOf) {
rule.oneOf = rule.oneOf.map(one => {
if (one.use === undefined) {
}
else if (Array.isArray(one.use)) {
one.use = one.use.map(innerFix)
}
else {
one.use = innerFix(one.use)
}
return one
})
}
return rule
})
return webpackConfig
}
function webpack(config) {
config = fixCssLoaderLocalIdent(config)
return config
}
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
reactStrictMode: true,
webpack,
i18n,
}