forked from DataDog/browser-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.base.js
More file actions
64 lines (59 loc) · 1.72 KB
/
webpack.base.js
File metadata and controls
64 lines (59 loc) · 1.72 KB
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
const path = require('path')
const { BannerPlugin } = require('webpack')
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
const buildEnv = require('./scripts/build-env')
const tsconfigPath = path.join(__dirname, 'tsconfig.base.json')
const SUFFIX_REGEXP = /-(us|eu)/
module.exports = ({ entry, mode, filename, datacenter }) => ({
entry,
mode,
output: {
filename,
path: path.resolve('./bundle'),
},
devtool: mode === 'development' ? 'inline-source-map' : 'false',
module: {
rules: [
{
test: /\.ts$/,
loader: 'string-replace-loader',
options: {
multiple: [
{ search: '<<< TARGET_DATACENTER >>>', replace: datacenter || 'us' },
{ search: '<<< SDK_VERSION >>>', replace: buildEnv.SDK_VERSION },
{ search: '<<< BUILD_MODE >>>', replace: buildEnv.BUILD_MODE },
],
},
},
{
test: /\.(ts|js)$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
configFile: tsconfigPath,
onlyCompileBundledFiles: true,
compilerOptions: {
module: 'es6',
allowJs: true,
},
},
},
],
},
resolve: {
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin({ configFile: tsconfigPath })],
},
plugins: [
new BannerPlugin({
banner({ filename }) {
const env = filename.match(SUFFIX_REGEXP)[1]
const newFileName = filename.replace(SUFFIX_REGEXP, '')
return `\n${filename} IS DEPRECATED, USE ${newFileName} WITH { site: 'datadoghq.${
env === 'eu' ? 'eu' : 'com'
}' } INIT CONFIGURATION INSTEAD\n`
},
include: SUFFIX_REGEXP,
}),
],
})