forked from ultimatecourses/angular-fundamentals-seed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·114 lines (111 loc) · 2.42 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
var server = require('webpack-dev-server');
var ts = require('awesome-typescript-loader');
var chalk = require('chalk');
var ProgressBarPlugin = require('progress-bar-webpack-plugin');
var jsonServer = require('json-server');
var cwd = process.cwd();
module.exports = {
cache: true,
context: cwd,
performance: {
hints: false
},
devServer: {
contentBase: cwd,
compress: true,
inline: true,
hot: true,
port: 4000,
publicPath: '/build/',
quiet: true,
historyApiFallback: true,
setup: function (app) {
app.use('/api', jsonServer.router('db.json'));
},
stats: {
chunks: false,
chunkModules: false
}
},
devtool: 'sourcemap',
entry: {
app: [
'reflect-metadata',
'ts-helpers',
'zone.js',
'main'
]
},
output: {
chunkFilename: '[name].chunk.js',
filename: '[name].js',
path: path.resolve(cwd, 'build'),
publicPath: '/build/',
sourceMapFilename: '[name].map'
},
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'awesome-typescript-loader'
},
{
loader: 'angular2-template-loader'
}
],
include: [
path.resolve(cwd, 'app')
]
},
{
test: /\.html/,
loader: 'raw-loader'
},
{
test: /\.scss$/,
use: [
{
loader: 'raw-loader'
},
{
loader: 'resolve-url-loader'
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
}
]
},
node: {
fs: 'empty',
global: true,
crypto: 'empty'
},
plugins: [
new webpack.DllReferencePlugin({
context: './',
manifest: require(path.resolve(cwd, 'vendor/vendor-manifest.json'))
}),
new webpack.NamedModulesPlugin(),
new ProgressBarPlugin({
format: chalk.magenta.bold('build') + ' [' + chalk.green(':bar')+ '] ' + chalk.green.bold(':percent') + ' ' + chalk.yellow.bold(':elapsed seconds') + ' ' + chalk.white(':msg'),
clear: false
}),
new ts.TsConfigPathsPlugin(),
new ts.CheckerPlugin(),
new webpack.HotModuleReplacementPlugin()
],
resolve: {
extensions: ['.ts', '.js'],
modules: ['node_modules', cwd]
}
};