-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrazzle.config.js
92 lines (83 loc) · 2.5 KB
/
razzle.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
86
87
88
89
90
91
92
const path = require('path');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
modify(config, { target, dev }, webpack) {
// Since RN web takes care of CSS, we should remove it for a #perf boost
/** @toggle: turn these on when you start adding css */
// config.module.rules = config.module.rules
// .filter(
// (rule) =>
// !(rule.test && rule.test.exec && rule.test.exec('./something.css')),
// )
// .filter(
// (rule) =>
// !(
// rule.test &&
// rule.test.exec &&
// rule.test.exec('./something.module.css')
// ),
// );
// const extPlugin = require(require.resolve('extract-text-webpack-plugin'));
// config.plugins = config.plugins.filter((w) => !(w instanceof extPlugin));
// // /** @endtoggle */
/** @config: SASS Loader Support */
const isServer = target !== 'web';
const postCssLoader = {
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [
autoprefixer({
browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9'],
}),
],
},
};
const sassLoader = {
loader: 'sass-loader',
options: {
includePaths: [path.resolve(__dirname, '../node_modules')],
},
};
config.module.rules.push({
test: /\.scss$/,
use: isServer
? ['css-loader', sassLoader]
: dev
? [
'style-loader',
{
loader: 'css-loader',
options: { modules: false, sourceMap: true },
},
postCssLoader,
sassLoader,
]
: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: { importLoaders: 1 },
},
postCssLoader,
sassLoader,
],
}),
});
if (!isServer && !dev) {
config.plugins.push(
new ExtractTextPlugin({
filename: 'static/css/[name].[contenthash:8].css',
allChunks: true,
}),
);
}
/** @endconfig */
// add ./src to module resolver so you can import modules with absolute path
config.resolve.modules.push('src');
config.devtool = dev ? 'eval-source-map' : 'none';
return config;
},
};