-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.ts
76 lines (72 loc) · 1.88 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
import * as ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import * as path from 'path'
import * as webpack from 'webpack'
import * as merge from 'webpack-merge'
const base = (mode: 'production' | 'development'): webpack.Configuration => {
const isProd = mode === 'production'
return {
mode,
entry: path.resolve(__dirname, 'src', 'index.ts'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: `aframe-vrm.module.js`,
library: 'vrm',
libraryTarget: 'umd',
globalObject: 'this'
},
module: {
rules: [
{
test: /\.ts?$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
},
{
test: /\.(glsl|frag|vert)$/,
use: 'raw-loader'
}
]
},
resolve: {
extensions: ['.js', '.ts'],
modules: ['node_modules']
},
// devServer: {
// port: 3000,
// contentBase: path.resolve(__dirname, './'),
// publicPath: '/lib/',
// openPage: 'examples/index.html',
// watchContentBase: true,
// inline: true
// },
plugins: [
new webpack.DefinePlugin({ 'process.env': { NODE_ENV: mode } }),
...(isProd
? []
: [new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true })])
],
devtool: isProd ? false : 'inline-source-map'
}
}
export default (env: any, argv: any): webpack.Configuration[] => {
const isProd = argv.mode === 'production'
return [
base(argv.mode),
merge(base(argv.mode), {
entry: path.resolve(__dirname, 'src', 'index.ts'),
output: {
filename: isProd ? 'aframe-vrm.min.js' : `aframe-vrm.js`,
library: '__aframe_vrm__',
libraryTarget: 'var'
},
externals: {
aframe: 'AFRAME'
}
})
]
}