-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
86 lines (75 loc) · 2.44 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
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
let languages = fs.readdirSync(path.join(__dirname, 'src', 'i18n'))
.map(file => path.join(__dirname, 'src', 'i18n', file))
.filter(path => !fs.statSync(path).isDirectory());
module.exports = {
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js', '.css'],
alias: {
'app': path.join(__dirname, 'src')
}
},
entry: {
vendor: [
'core-js/es6',
'core-js/es7/reflect',
'zone.js/dist/zone'
],
main: [
...languages,
path.join(__dirname, 'src', 'main.ts')
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
sourceMapFilename: '[name].map',
},
module: {
rules: [
{ test: /\.ts$/, use: ['awesome-typescript-loader'] },
{
test: /\.ya?ml$/,
use: [
{
loader: 'file-loader',
options: { name: 'assets/i18n/[name].json' }
},
{
loader: 'yaml-import-loader',
options: { importRoot: true, output: 'json' }
}
],
include: path.join(__dirname, 'src', 'i18n')
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ name: ['main', 'vendor'] }),
new HtmlWebpackPlugin({
base: process.env.NODE_ENV === 'production'
? 'https://ngfk.github.io/ngx-translate-yaml/'
: '/',
template: path.join(__dirname, 'src', 'index.ejs')
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
// Provide context to Angular's use of System.import
// https://github.com/angular/angular/issues/11580
// https://github.com/angular/angular/issues/14898 (modification for angular 4)
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
path.join(__dirname, 'src'),
{ } // Routes, if any
),
],
devServer: {
port: 9000,
contentBase: './src'
}
}