This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
forked from jeremybarbet/next-classnames-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
85 lines (68 loc) · 2.01 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// @ts-ignore
require('dotenv').config();
const path = require('path');
const sass = require('@zeit/next-sass');
const typescript = require('@zeit/next-typescript');
const plugins = require('next-compose-plugins');
const images = require('next-images');
const fonts = require('next-fonts');
const reactSvg = require('next-react-svg');
// let loader = {};
// const isProd = process.env.NODE_ENV === 'production';
// console.log('-isProd', isProd);
// if (isProd){
// loader = require('./next-classnames.js');
// }
// console.log('-loader', loader);
const nextConfig = {
serverRuntimeConfig: {
/*
* Will only be available on the server side
* Use `import { config } from 'utils/config';`
*/
},
publicRuntimeConfig: {
/*
* Will be available on both server and client
* Use `import { config } from 'utils/config';`
*/
},
webpack(config) {
// if (!isProd) {
// const classNamesLoader = require.resolve('next-classnames-loader');
// const styleRules = config.module.rules.filter(rule => rule.test.test('file.scss') || rule.test.test('file.sass'));
// styleRules.forEach(styleRule => {
// if (styleRule.use && styleRule.use.indexOf(classNamesLoader) === -1) {
// styleRule.use.splice(0, 0, classNamesLoader);
// }
// });
// }
config.resolve = config.resolve || {};
config.resolve.modules = [
path.join(__dirname, 'src'),
path.join(__dirname, 'node_modules'),
];
return config;
},
};
module.exports = plugins([
// loader,
[sass, {
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: '[local]___[hash:base64:5]',
},
webpack: (config) => {
config.module.rules.unshift({
test: /\.scss$/,
use: 'next-classnames-loader',
});
return config;
},
}],
[images, { exclude: path.resolve(__dirname, 'src/assets/svg') }],
[reactSvg, { include: path.resolve(__dirname, 'src/assets/svg') }],
fonts,
typescript,
], nextConfig);