forked from shuyunyu/vin3gis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
97 lines (95 loc) · 2.59 KB
/
webpack.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
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const htmlwp = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const packageJson = require('./package.json');
const fs = require('fs');
const entryFile = "./src/index.ts";
const exportVersionStr = "export const version = '" + packageJson.version + "';";
const regex = /export const version = '\d+.\d+.\d+';/g;
let indexContent = fs.readFileSync(entryFile, "utf-8");
if (regex.test(indexContent)) {
indexContent = indexContent.replace(regex, exportVersionStr)
fs.writeFileSync(entryFile, indexContent);
} else {
fs.appendFileSync(entryFile, exportVersionStr);
}
module.exports = {
mode: 'development',
entry: {
"Vin3GIS": entryFile,
"TestCase": './test/index.ts'
},
output: {
path: __dirname + '/dist',
filename: '[name].js',
library: '[name]'
},
//不打包THREE
externals: {
three: 'THREE'
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
plugins: [
new htmlwp({
title: 'webgl',
template: 'index.html',
scriptLoading: 'blocking'
}),
new UglifyJSPlugin({
uglifyOptions: {
ie8: true,
ecma: 5,
warnings: false,
output: {
beautify: false
}
}
}),
new CopyPlugin({
patterns: [
{ from: "./public", to: "./" }
]
})
],
module: {
rules: [
{
test: /worker\.js?$/,
use: {
loader: path.resolve(__dirname, "./loader/worker-loader/worker_loader.js"),
options: {
uglify: false
}
},
exclude: /node_modules/
},
{
test: /\.(glsl)$/,
use: {
loader: path.resolve(__dirname, "./loader/glsl-loader/glsl_loader.js"),
options: {
base64Encode: true
}
}
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}, {
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
watch: false,
devServer: {
compress: true,
historyApiFallback: true,
hot: true,
port: 8866,
}
}