-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
webpack.config.ts
85 lines (81 loc) · 2.85 KB
/
webpack.config.ts
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
// This webpack builds the examples, the library dist files are built with tsc
import path from 'path';
import webpack from 'webpack';
import 'webpack-dev-server';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import {TsconfigPathsPlugin} from 'tsconfig-paths-webpack-plugin';
const webpackConfig = (env): webpack.Configuration => {
const conf: webpack.Configuration = {
entry: './examples/index.tsx',
...(env.production || !env.development ? {} : {devtool: 'eval-source-map'}),
resolve: {
alias: {
rlayers: path.resolve(__dirname, 'src')
},
extensions: ['.ts', '.tsx', '.js'],
//TODO waiting on https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/61
//@ts-ignore
plugins: [new TsconfigPathsPlugin()]
},
output: {
path: path.join(__dirname, '/docs'),
filename: 'bundle.js'
},
// https://github.com/TypeStrong/ts-loader/issues/751
ignoreWarnings: [{message: /export .* was not found in/}],
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: 'examples/tsconfig.json'
}
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/,
loader: 'svg-url-loader'
},
{
test: /\.md$/,
use: ['html-loader', 'markdown-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './examples/index.html'
}),
new webpack.DefinePlugin({
process: {
env: {
RLAYERS_DEBUG: !env.production || env.development
}
},
VERSION: JSON.stringify(require('./package.json').version),
MAPBOX_TOKEN: JSON.stringify(process.env.MAPBOX_TOKEN),
STADIA_MAPS_API_KEY: JSON.stringify(process.env.STADIA_MAPS_API_KEY)
})
],
devServer: {
port: 8030,
headers: process.env.COOP
? {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp'
}
: undefined
}
};
if (!env.development) {
conf.plugins!.push(new ForkTsCheckerWebpackPlugin());
}
return conf;
};
export default webpackConfig;