Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module.exports = {
webpack: (config) => {
config.module.rules.push(
// yaml
{
test: /\.yaml$/,
use: [
{
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
'json-loader',
'yaml-loader'
]
},
// CSS rule for module css (mostly global)
{
test: /\.css$/,
include (str) {
return /node_modules/.test(str)
},
exclude (str) {
return !/node_modules/.test(str)
},
use: [
{
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
'raw-loader',
'val-loader',
{
loader: 'skeleton-loader',
options: {
procedure: (content) => (
`${content} \n` + ['module.exports = {',
'stylesheet: module.exports.toString(),',
'classNames: exports.locals',
'}'
].join('')
)
}
},
{
loader: 'css-loader',
options: {
modules: true,
minimize: true,
importLoaders: 1,
localIdentName: '[local]' // no local hash name for antd global css names
}
}
]
},
// CSS rule for internal scoped css
{
test: /\.css$/,
include (str) {
return !/node_modules/.test(str)
},
exclude (str) {
return /node_modules/.test(str)
},
use: [
{
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
'raw-loader',
'val-loader',
{
loader: 'skeleton-loader',
options: {
procedure: (content) => (
`${content} \n` + ['module.exports = {',
'stylesheet: module.exports.toString(),',
'classNames: exports.locals',
'}'
].join('')
)
}
},
{
loader: 'css-loader',
options: {
modules: true,
minimize: true,
importLoaders: 1,
localIdentName: '[local]-[hash:base64:5]'
}
}
]
}
)
return config
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.