-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.sw.js
122 lines (101 loc) · 3.61 KB
/
webpack.config.sw.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
const ClosureCompiler = require('google-closure-compiler-js').webpack;
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const ngtools = require('@ngtools/webpack');
const CompressionPlugin = require("compression-webpack-plugin");
//const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const buildTime = Date.now()
const ClosureCompilerPlugin = require('webpack-closure-compiler');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const AngularServiceWorkerPlugin = require('@angular/service-worker/webpack').default;
const config = {
context: path.join(__dirname + '/src'),
entry: {
'sw': './sw.ts'
},
// enable loading modules relatively
resolve: {
extensions: ['.ts', '.js'],
// modules: [__dirname + "/src", "node_modules"]
},
module: {
loaders: [
{ test: /\.scss$/, loaders: ['raw-loader', 'sass-loader'] },
{ test: /\.css$/, loader: 'raw-loader' },
{ test: /\.html$/, loader: 'raw-loader', exclude: [path.join(__dirname, './src/index.html')] },
{ test: /\.ts$/, loaders: ['@ngtools/webpack'], exclude: /\node.ts$/ },
]
},
plugins: [
new ngtools.AotPlugin({
tsConfigPath: './tsconfig.aot.json',
entryModule: path.join(__dirname, 'src/app/app.module') + '#AppModule',
baseDir: root('src'),
typeChecking: false,
}),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
root('./src')
),
// new ClosureCompiler({
// options: {
// languageIn: 'ECMASCRIPT6',
// languageOut: 'ECMASCRIPT5',
// compilationLevel: 'SIMPLE',
// warningLevel: 'QUIET'
// },
// }),
// new ClosureCompilerPlugin({
// compiler: {
// language_in: 'ECMASCRIPT6',
// language_out: 'ECMASCRIPT5',
// compilation_level: 'ADVANCED'
// },
// concurrency: 3,
// }),
// new ServiceWorkerWebpackPlugin({
// entry: path.join(__dirname, 'src/sw.js'),
// }),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
},
output: {
comments: false,
},
}),
],
output: {
path: path.join(__dirname, "dist/www"),
filename: "[name].bundle.js",
chunkFilename: "[id].bundle.js",
},
devServer: {
historyApiFallback: true,
port: 3535,
contentBase: './src',
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
},
};
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
module.exports = config;