This repository has been archived by the owner on Mar 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
62 lines (58 loc) · 1.67 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
/* eslint-env node */
const path = require( 'path' );
const ForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' );
const HtmlWebpackPlugin = require( 'html-webpack-plugin' );
const webpack = require( 'webpack' );
module.exports = ( env, argv ) => {
const DEBUG = argv.mode === 'development';
return {
entry: path.resolve( __dirname, 'src/main.ts' ),
output: {
path: path.resolve( __dirname, 'dist' ),
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.(png|jpg|gif|ttf|otf)$/, use: 'url-loader' },
{ test: /\.(sass|scss|css)$/, use: [ 'style-loader', 'css-loader' ] },
{ test: /\.(sass|scss)$/, use: 'sass-loader' },
{ test: /\.(glsl|frag|vert)$/, use: [ 'raw-loader', 'scarlett-glslify-loader' ] },
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: { happyPackMode: true, transpileOnly: true }
}
]
},
{ test: /\.js$/, use: 'babel-loader' },
]
},
resolve: {
modules: [ 'node_modules' ],
extensions: [ '.ts', '.js' ],
},
optimization: {
minimize: !DEBUG
},
devServer: {
inline: true,
hot: true
},
plugins: [
new webpack.DefinePlugin( {
'process.env': { DEBUG: DEBUG },
} ),
new HtmlWebpackPlugin( {
template: './src/html/index.html'
} ),
...( DEBUG ? [
new webpack.NamedModulesPlugin(),
new ForkTsCheckerWebpackPlugin( { checkSyntacticErrors: true } ),
] : [] ),
],
devtool: DEBUG ? 'inline-source-map' : false
};
};