mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
56f52db5a9
* Fixed: css-modules reload files styles.css.json. * update: disable uglify for next build. add: require('fs') for next build. add: disable uglify on next.config.js for next build. * Fix linting errors
45 lines
1 KiB
JavaScript
45 lines
1 KiB
JavaScript
const fs = require('fs')
|
|
const trash = require('trash')
|
|
|
|
module.exports = {
|
|
webpack: (config) => {
|
|
config.plugins = config.plugins.filter(
|
|
(plugin) => (plugin.constructor.name !== 'UglifyJsPlugin')
|
|
)
|
|
|
|
config.module.rules.push(
|
|
{
|
|
test: /\.css$/,
|
|
use: [
|
|
{
|
|
loader: 'emit-file-loader',
|
|
options: {
|
|
name: 'dist/[path][name].[ext]'
|
|
}
|
|
},
|
|
{
|
|
loader: 'skeleton-loader',
|
|
options: {
|
|
procedure: function (content) {
|
|
const fileName = `${this._module.userRequest}.json`
|
|
const classNames = fs.readFileSync(fileName, 'utf8')
|
|
|
|
trash(fileName)
|
|
|
|
return ['module.exports = {',
|
|
`classNames: ${classNames},`,
|
|
`stylesheet: \`${content}\``,
|
|
'}'
|
|
].join('')
|
|
}
|
|
}
|
|
},
|
|
'postcss-loader'
|
|
]
|
|
}
|
|
)
|
|
|
|
return config
|
|
}
|
|
}
|