-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnext.config.js
41 lines (34 loc) · 1.28 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const withTM = require('next-transpile-modules')([]);
const withPlugins = require('next-compose-plugins');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = withPlugins([withTM], {
reactStrictMode: true,
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Find and remove NextJS css rules.
const cssRulesIdx = config.module.rules.findIndex((r) => r.oneOf);
if (cssRulesIdx === -1) {
throw new Error('Could not find NextJS CSS rule to overwrite.');
}
config.module.rules.splice(cssRulesIdx, 1);
// temporarily reoslve bootstrap usage issue
delete config.module.generator.asset.filename;
// Add a simpler rule for global css anywhere.
config.plugins.push(
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'static/chunks/pages/[contenthash].css',
chunkFilename: 'static/chunks/pages/[contenthash].css',
}),
);
config.module.rules.push({
test: /\.(sa|sc|c)ss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
});
config.module.rules.push({
test: /\.tsx/,
use: [defaultLoaders.babel],
});
return config;
},
});