yarn add webpack@webpack-4
在.babelrc引入
"plugins": [
? ? [
? ? ? "import",
? ? ? {
? ? ? ? "libraryName": "antd",
? ? ? ? // true 的時候才會編譯less
? ? ? ? "style": true
? ? ? }
? ? ],
修改在next.config.js
withCSS({
? ? // 添加
? ? cssModules: true,
? ? cssLoaderOptions: {
? ? ? importLoaders: 1,
? ? ? localIdentName: "[local]___[hash:base64:5]"
? ? },
? ? ...withLess(
? ? ? withSass({
? ? ? ? lessLoaderOptions: {
? ? ? ? ? javascriptEnabled: true
? ? ? ? }
? ? ? })
? ? ),