-
Notifications
You must be signed in to change notification settings - Fork 136
/
craco.config.js
101 lines (98 loc) · 2.69 KB
/
craco.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
93
94
95
96
97
98
99
100
101
const {CracoAliasPlugin} = require('react-app-alias-ex');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const CracoLessPlugin = require('craco-less');
const {getThemeVariables} = require('antd/dist/theme');
const lodash = require('lodash');
const path = require('path');
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const isDevelopment = process.env.NODE_ENV !== 'production';
const additionalWebpackPlugins =
isDevelopment || !process.env.SENTRY_AUTH_TOKEN
? []
: [
new SentryWebpackPlugin({
org: 'kubeshop',
project: 'monokle-desktop',
include: './build',
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
];
module.exports = {
webpack: {
plugins: {
add: [
new MonacoWebpackPlugin({
languages: ['yaml'],
globalAPI: true,
customLanguages: [
{
label: 'yaml',
entry: 'monaco-yaml',
worker: {
id: 'monaco-yaml/yamlWorker',
entry: 'monaco-yaml/yaml.worker',
},
},
],
}),
...additionalWebpackPlugins,
],
},
devtool: 'source-map',
configure: webpackConfig => {
webpackConfig.node = {__dirname: false};
webpackConfig.target = 'electron-renderer';
webpackConfig.optimization = {
moduleIds: 'deterministic',
minimize: false,
};
webpackConfig.output = {
filename: 'bundle.[name].js',
path: path.resolve(__dirname, 'build'),
};
webpackConfig.externals = {
fsevents: "require('fsevents')",
};
// Temporary solution until react-scripts 5.0.1 is released
webpackConfig.ignoreWarnings = [/Failed to parse source map/];
return webpackConfig;
},
},
babel: {
presets: [],
plugins: [
process.env.NODE_ENV === 'development'
? ['babel-plugin-styled-components', {displayName: true, namespace: 'dev'}]
: [{}],
],
},
jest: {
configure: jestConfig =>
lodash.merge(jestConfig, {
setupFilesAfterEnv: ['<rootDir>/jest.env.js'],
transform: {
// https://github.com/gsoft-inc/craco/issues/353#issuecomment-1003301013
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': './lib/jest-babel-transform.js',
},
}),
},
plugins: [
{
plugin: CracoAliasPlugin,
options: {},
},
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: getThemeVariables({
dark: true,
}),
javascriptEnabled: true,
},
},
},
},
],
};