-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
143 lines (134 loc) · 3.5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
const helpers = require('./webpack.helpers');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const poststylus = require('poststylus');
const ENV = process.env.ENV || 'development';
const ngPkg = require('@angular/common/package');
const metadata = {
title : 'Survarium stats',
description: 'Статистика игроков, матчей, кланов Survarium. Стримы Survarium. Сообщения разработчиков Survarium.',
baseUrl : 'http://survarium.test:3000/',
host : 'survarium.test',
port : 3000,
ENV : ENV,
API_PATH : process.env.API_PATH || 'https://survarium.pro/api',
version : helpers.version,
updated : helpers.updated,
ngVersion : ngPkg.version
};
/*
* Config
*/
module.exports = {
metadata: metadata,
devtool : 'eval',
debug : true, // cache: false,
entry: {
'vendor': './app/vendor.ts',
'main' : './app/bootstrap.ts'
},
output: {
path : helpers.root('dist'),
filename : '[name].bundle.js',
sourceMapFilename: '[name].bundle.map',
chunkFilename : '[id].chunk.js'
},
resolve: {
// ensure loader extensions match
extensions: helpers.prepend(['.ts', '.js', '.json', '.css', '.html', '.styl'])
},
module: {
preLoaders: [],
loaders : [
{
test : /\.ts$/,
loader : 'ts-loader',
exclude: [/\.(spec|e2e|async)\.ts$/]
},
{
test : /\.json$/,
loader: 'json-loader'
},
{
test : /\.css$/,
loader: 'raw-loader'
},
{
test : /\.html$/,
loader : 'raw-loader!html-minify-loader',
exclude: [helpers.root('app/index.html')]
},
{
test: /\.styl$/,
loader: 'raw-loader!stylus-loader'
}
]
},
plugins: [
new webpack.ProvidePlugin({
'Chart': 'chart.js'
}),
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.CommonsChunkPlugin({
name : 'vendor',
filename : 'vendor.bundle.js',
minChunks: Infinity
}), // static assets
new CopyWebpackPlugin([{
from: 'app/assets',
to : 'assets'
}]), // generating html
new HtmlWebpackPlugin(Object.assign({}, helpers.HtmlWebpackPluginParams, { minify: false })),
new webpack.DefinePlugin({
'process.env': {
'ENV' : JSON.stringify(metadata.ENV),
'NODE_ENV': JSON.stringify(metadata.ENV),
'API_PATH': JSON.stringify(metadata.API_PATH),
'TITLE' : JSON.stringify(metadata.title),
'VERSION' : JSON.stringify(metadata.version),
'UPDATED' : JSON.stringify(metadata.updated),
'APP_DESCRIPTION': JSON.stringify(metadata.description),
'NG_VERSION': JSON.stringify(metadata.ngVersion)
}
})],
// Other module loader config
tslint : {
emitErrors : true,
failOnHint : false,
resourcePath: 'app'
},
devServer: {
port : metadata.port,
host : metadata.host, // contentBase: 'src/',
disableHostCheck: true,
historyApiFallback: true,
watchOptions : {
aggregateTimeout: 300,
poll : 1000
},
progress: true,
colors: true
},
// we need this due to problems with es6-shim
node : {
global : 'window',
progress : false,
crypto : 'empty',
module : false,
clearImmediate: false,
setImmediate : false
},
stylus: {
use: [
poststylus([ 'autoprefixer', 'rucksack-css' ])
]
},
'html-minify-loader': {
quotes: true,
loose: true,
dom: {
lowerCaseAttributeNames: false
}
}
};