blob: db33a94f3ea2865a671ef9e127da4e5d585fb1f3 [file] [log] [blame]
Michael Landoed64b5e2017-06-09 03:19:04 +03001'use strict';
2
3const path = require('path');
4const merge = require('webpack-merge');
5const webpack = require('webpack');
6const ServerConfig = require('./webpack.server');
7const webpackCommonConfig = require('./webpack.common');
8const {GlobCopyWebpackPlugin, BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack');
9const CopyWebpackPlugin = require('copy-webpack-plugin');
10
Michael Lando6e600062017-06-19 19:51:24 +030011var currentTime = new Date().getTime();
12
Michael Landoed64b5e2017-06-09 03:19:04 +030013const params = {
14 // entryPoints: [
15 // '/sdc1/scripts/inline',
16 // '/sdc1/scripts/polyfills',
17 // '/sdc1/scripts/vendor',
18 // '/sdc1/scripts/main',
19 // '/sdc1/scripts/sw-register',
20 // '/sdc1/scripts/scripts',
21 // '/sdc1/scripts/styles'
22 // ]
23};
24
25const webpackProdConfig = {
26 module: {
Michael Lando6e600062017-06-19 19:51:24 +030027 rules: [
28 {test: /\.(eot|svg)$/, loader: "file-loader?name=/scripts/fonts/[name].[hash:20].[ext]"},
29 {
30 test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
31 loader: "url-loader?name=/scripts/images/[name].[hash:20].[ext]&limit=10000"
32 }
33 ]
Michael Landoed64b5e2017-06-09 03:19:04 +030034 },
35 output: {
36 path: path.join(process.cwd(), "dist"),
Michael Lando6e600062017-06-19 19:51:24 +030037 filename: "[name]." + currentTime + ".bundle.js",
Michael Landoed64b5e2017-06-09 03:19:04 +030038 chunkFilename: "[id].chunk.js",
39 publicPath: "/sdc1"
40 },
Michael Lando6e600062017-06-19 19:51:24 +030041 plugins: [
Michael Landoed64b5e2017-06-09 03:19:04 +030042 new webpack.DefinePlugin({
43 __DEBUG__: JSON.stringify(false),
44 __ENV__: JSON.stringify('prod')
45 }),
Michael Lando6e600062017-06-19 19:51:24 +030046
Michael Landoed64b5e2017-06-09 03:19:04 +030047 new CopyWebpackPlugin([
Michael Lando6e600062017-06-19 19:51:24 +030048 {
49 from: './src/index.html', transform: function (content, path) {
50 content = (content + '').replace(/\.bundle/g, '.' + currentTime + '.bundle');
51 return content;
52 }
53 }
Michael Landoed64b5e2017-06-09 03:19:04 +030054 ]),
Michael Lando6e600062017-06-19 19:51:24 +030055 new webpack.optimize.UglifyJsPlugin({
Michael Landoed64b5e2017-06-09 03:19:04 +030056 beautify: false,
57 mangle: {
58 screw_ie8: true,
59 keep_fnames: true
60 },
61 compress: {
62 warnings: false,
63 screw_ie8: true
64 },
65 comments: false
66 })
Michael Lando6e600062017-06-19 19:51:24 +030067 ]
Michael Landoed64b5e2017-06-09 03:19:04 +030068};
69
70module.exports = merge(webpackProdConfig, webpackCommonConfig(params));