forked from K15t/aui-ng2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-config.js
130 lines (119 loc) · 4.29 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
var master = require('k15t-webpack-build/webpack-master-config.js');
var utils = require('k15t-webpack-build/utils.js');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
var path = require('path');
if (process.env.testMode === 'true') {
module.exports = master({
metadata: {
appPrefix: 'auiNg'
},
basePath: '',
autoWatch: true,
autoWatchBatchDelay: 300,
output: {
path: './target'
},
module: {
noParse: [
utils.getAbsolutePath('zone.js/dist')
]
}
});
} else {
var targetDir;
var testingEnabled = (process.env.testMode === 'true' || process.env.testMode === true) || false;
var devModeEnabled = (process.env.devMode === 'true' || process.env.devMode === true) || false;
if (process.env.release === 'true') {
targetDir = './dist';
} else if (process.env.npm_config_releasedemo === 'true') {
targetDir = './public';
} else {
targetDir = './target';
}
module.exports = master({
metadata: {
contextPath: process.env.npm_config_releasedemo === 'true' ? '/aui-ng2' : '',
appPrefix: 'auiNg'
},
module: {
preLoaders: [
{
test: /\.ts$/,
loader: 'tslint-loader',
exclude: [
/node_modules/
]
},
{
test: /\.ts|\.js$/,
loader: 'string-replace',
query: {
search: '"use strict";',
replace: '',
flags: 'i'
}
}],
loaders: [
{
test: /\.ts$/,
loader: 'ts-loader',
query: {
// remove TypeScript helpers to be injected below by DefinePlugin
'compilerOptions': {
'removeComments': !devModeEnabled,
'noEmitHelpers': !devModeEnabled
},
'ignoreDiagnostics': [
2403, // 2403 -> Subsequent variable declarations
2300, // 2300 -> Duplicate identifier
2374, // 2374 -> Duplicate number index signature
2375 // 2375 -> Duplicate string index signature
]
},
compilerOptions: './tsconfig.json',
exclude: testingEnabled ? [] : [/\.(spec)\.ts$/]
},
{test: /\.json$/, loader: 'json-loader'},
{test: /\.css$/, loader: 'raw-loader'},
{test: /\.html$/, loader: 'raw-loader'}
]
},
entry: {
main: './demo/main.ts',
vendor: './demo/vendor.ts'
},
envProperties: {
PRODUCT_VERSION: require("./package.json").version,
BUILD_TIME: (new Date).toLocaleString()
},
output: {
filename: './demo/[name].min.js',
sourceMapFilename: './demo/[name].map',
chunkFilename: './demo/[id].chunk.js',
path: targetDir,
publicPath: process.env.npm_config_releaseDemo === 'true' ? 'http://k15t.github.io/aui-ng2/' : ''
},
addPlugins: function(devModeEnabled, testingEnabled, debugModeEnabled) {
var plugins = [];
if (process.env.release === 'true') {
plugins.push(new CopyWebpackPlugin([{
from: 'src',
to: '.'
}]));
}
plugins.push(new HtmlWebpackPlugin({
filename: 'index.html',
template: './demo/index.html',
inject: false
}));
plugins.push(new CommonsChunkPlugin({
name: 'vendor',
filename: './demo/[name].min.js',
minChunks: Infinity
}));
return plugins;
}
});
}