-
Notifications
You must be signed in to change notification settings - Fork 0
/
razzle.config.js
66 lines (66 loc) · 2.32 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
module.exports = {
options: {
verbose: true,
debug: {
compile: true,
},
},
modifyWebpackConfig({ env: { dev }, webpackConfig, paths }) {
// first copy the inbound options to change the source map tool
const newWebpackConfig = {
...webpackConfig,
devtool: dev ? 'inline-source-map' : 'source-map', // Slowest but the best source map with inlined source code
};
// Add .svg and .ico loaders
newWebpackConfig.module.rules.push(
{
test: /\.svg$/,
use: [{ loader: require.resolve('svg-url-loader') }],
},
{
test: /favicon\.ico$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve('url-loader'),
options: {
limit: 1,
mimetype: 'image/x-icon',
name: '[name].[ext]',
},
},
],
}
);
// Update the resolver to look in our /src directory first and add a few extensions as well
newWebpackConfig.resolve = {
...newWebpackConfig.resolve,
modules: [`${paths.appPath}/src`, ...newWebpackConfig.resolve.modules],
extensions: [...webpackConfig.resolve.extensions, '.svg'],
};
// Uncomment this to debug the new webpack config
// console.dir(newWebpackConfig, { depth: null });
return newWebpackConfig;
},
modifyJestConfig({ jestConfig }) {
const customJestConfig = {
automock: false,
setupFiles: ['<rootDir>/src/__tests__/__setup__/initJest.js'],
setupFilesAfterEnv: ['<rootDir>/node_modules/jest-enzyme/lib/index.js'],
modulePathIgnorePatterns: ['<rootDir>[/\\\\](build|docs|node_modules|scripts)[/\\\\]'],
testEnvironment: 'jest-environment-jsdom-global',
transform: {
'src/client.jsx': '<rootDir>/src/__tests__/__setup__/hotModulesPreprocessor.js',
'src/index.jsx': '<rootDir>/src/__tests__/__setup__/hotModulesPreprocessor.js',
'\\.[jt]sx?$': 'babel-jest',
},
coverageDirectory: '<rootDir>/coverage/',
collectCoverage: true,
coveragePathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/src/__tests__'],
};
const newJestConfig = { ...jestConfig, ...customJestConfig };
// Uncomment this to debug the new jest config
// console.dir(newJestConfig, { depth: null });
return newJestConfig;
},
};