-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
113 lines (108 loc) · 3.98 KB
/
webpack.common.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const cesiumConfig = require('@oidajs/map-cesium/config/webpack.cesium.js');
const antdConfig = require('@oidajs/ui-react-antd/config/webpack.antd.js');
const { merge } = require('webpack-merge');
const config = (env = {}) => {
return merge(
cesiumConfig({ nodeModulesDir: 'node_modules' }),
antdConfig({
styleLoader: env.mode === 'production' ? MiniCssExtractPlugin.loader : 'style-loader'
}),
{
entry: {
app: './src/index.tsx'
},
output: {
path: env.outpath || path.resolve(__dirname, "dist"),
filename: '[name].[contenthash].bundle.js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
symlinks: false,
fallback: {
util: require.resolve("util/")
}
},
target: 'web',
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
]
},
{
include: /oidajs[\/\\]/,
test: /\.jsx?$/,
enforce: 'pre',
use: [
{
loader: 'source-map-loader'
}
]
},
{
test: /\.jsx?$/,
include:[
path.resolve(__dirname, "node_modules/geotiff")
],
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: path.resolve(__dirname, 'tsconfig.json'),
compilerOptions: {
sourceMap: false
},
onlyCompileBundledFiles: true
}
}
]
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'assets/images/[name].[contenthash].[ext]'
}
}
]
},
{
test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
use: [
{
loader: 'file-loader',
options: {
name: 'assets/fonts/[name].[contenthash].[ext]'
}
}
]
},
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.ejs',
baseUrl: env.baseUrl || '/',
appVersion: env.appVersion || 'dev',
minify: false
})
]
}
)
};
module.exports = config;