-
Notifications
You must be signed in to change notification settings - Fork 1
/
karma.webpack.conf.js
128 lines (127 loc) · 4.22 KB
/
karma.webpack.conf.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const Path = require( "path" );
const os = require("os");
var webpack = require('webpack');
module.exports = function( config ) {
config.set( {
frameworks: [
"jasmine",
"webpack",
],
client: {
jasmine: {
random: false
}
},
files: ['test/react/webpack.tests.js'],
preprocessors: {
"test/react/webpack.tests.js": ["webpack", "sourcemap"],
},
webpack: {
mode: "development",
devtool: 'inline-source-map', // sourcemap support
output: {
filename: '[name].js',
path: Path.join(__dirname, 'test/dist/_karma_webpack_') + Math.floor(Math.random() * 1000000),
},
externals: [
'emotion',
'@emotion/react',
'@emotion/css',
//'@grafana/runtime', // this is commented in favor of the NormalModuleReplacementPlugin entry below.
//'@grafana/ui', // this is commented in favor of the NormalModuleReplacementPlugin entry below.
'@grafana/slate-react',
'react-redux',
'redux',
'react-router',
'react-router-dom',
'd3',
'slate',
'slate-plain-serializer',
'prismjs',
'jquery',
'moment',
'angular',
],
module: {
rules: [
{
test: /src\/(?:.*\/)?module\.tsx?$/,
use: [
{
loader: 'imports-loader',
options: {
imports: `side-effects grafana-public-path`,
},
},
],
},
{
exclude: /(node_modules)/,
test: /\.[tj]sx?$/,
use: {
loader: 'swc-loader',
options: {
jsc: {
baseUrl: Path.resolve(process.cwd(), "./src"),
target: 'es2015',
loose: false,
parser: {
syntax: 'typescript',
tsx: true,
decorators: false,
dynamicImport: true,
},
},
},
},
},
],
},
plugins: [
new webpack.NormalModuleReplacementPlugin(/@grafana\/runtime/, "../test/react/LocationService.ts"),
new webpack.NormalModuleReplacementPlugin(/@grafana\/ui/, "../../test/react/TextArea.tsx"),
],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
// handle resolving "rootDir" paths
modules: [Path.resolve(process.cwd(), 'src'), 'node_modules'],
fallback: {
"fs": false,
"util": false,
"stream": false,
"tty": require.resolve("tty-browserify"),
}
},
stats: {
modules: false,
colors: true,
},
watch: false,
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
minSize: 0,
cacheGroups: {
commons: {
name: 'commons',
chunks: 'initial',
minChunks: 1,
},
},
},
}
},
client: {
captureConsole: true,
},
reporters: ['dots'],
exclude: [
"src/components/lib/leaflet.js",
"src/components/old/*"
],
browsers: ["ChromeHeadless"],
webpackMiddleware: { noInfo: true },
browserNoActivityTimeout: 60000 // 60s; wait for webpack to compile :-(
} );
};