-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwebpack.base.ts
62 lines (59 loc) · 1.5 KB
/
webpack.base.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
import webpack from 'webpack';
import { resolveByRootDir, DIST } from '../script/util';
let isProduction = process.env.NODE_ENV === 'production';
const config: webpack.Configuration = {
entry: resolveByRootDir('index.ts'),
resolve: {
extensions: ['.ts', '.js'],
modules: [resolveByRootDir('example'), resolveByRootDir('common'), 'node_modules'],
alias: {
'@': resolveByRootDir('example'),
common: resolveByRootDir('common'),
},
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
include: [resolveByRootDir('index.ts'), resolveByRootDir('example'), resolveByRootDir('common')],
exclude: /node_modules/,
},
{
test: /\.(png|jpg|jpeg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[hash].[ext]',
outputPath: 'images/',
publicPath: isProduction ? `${DIST}/images/` : '',
},
},
],
},
{
test: /\.(mp3)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[hash].[ext]',
outputPath: 'media/',
publicPath: isProduction ? `${DIST}/media/` : '',
},
},
],
},
],
},
target: 'web',
stats: {
assets: true,
colors: true,
errors: true,
warnings: true,
},
plugins: [new webpack.EnvironmentPlugin(['NODE_ENV'])],
};
export default config;