blob: 71fc3ab9f72302dd822aab99a19a6227217a4b82 [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');
Michael Lando6e600062017-06-19 19:51:24 +03008const {BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack');
Michael Landoed64b5e2017-06-09 03:19:04 +03009const CopyWebpackPlugin = require('copy-webpack-plugin');
10
11// Print server configuration
12//process.stdout.write('webpack.server: ' + JSON.stringify(ServerConfig) + '\n');
13//process.stdout.write('webpack.common: ' + JSON.stringify(webpackCommonConfig) + '\n');
Michael Lando6e600062017-06-19 19:51:24 +030014var currentTime = new Date().getTime();
15
Michael Landoed64b5e2017-06-09 03:19:04 +030016const params = {
17 // entryPoints: [
18 // '/scripts/inline',
19 // '/scripts/polyfills',
20 // '/scripts/vendor',
21 // '/scripts/main',
22 // '/scripts/sw-register',
23 // '/scripts/scripts',
24 // '/scripts/styles'
25 // ]
26};
27
Michael Lando6e600062017-06-19 19:51:24 +030028module.exports = function (env) {
Michael Landoed64b5e2017-06-09 03:19:04 +030029
30 const webpackDevConfig = {
31 devtool: "source-map",
32 devServer: ServerConfig(env),
33 module: {
34 rules: [
Michael Lando6e600062017-06-19 19:51:24 +030035 {test: /\.(eot|svg)$/, loader: "file-loader?name=scripts/fonts/[name].[hash:20].[ext]"},
36 {
37 test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
38 loader: "url-loader?name=scripts/images/[name].[hash:20].[ext]&limit=10000"
39 }
Michael Landoed64b5e2017-06-09 03:19:04 +030040 ]
41 },
42 output: {
43 path: path.join(process.cwd(), "dist"),
Michael Lando6e600062017-06-19 19:51:24 +030044 filename: "[name]." + currentTime + ".bundle.js",
Michael Landoed64b5e2017-06-09 03:19:04 +030045 chunkFilename: "[id].chunk.js"
46 //publicPath: "/"
47 },
48 plugins: [
Michael Lando6e600062017-06-19 19:51:24 +030049
Michael Landoed64b5e2017-06-09 03:19:04 +030050 // Replace /sdc1 inside index.html with '' (because /sdc1 is used only in production).
51 new CopyWebpackPlugin([
Michael Lando6e600062017-06-19 19:51:24 +030052 {
53 from: './src/index.html', transform: function (content, path) {
54 content = (content + '').replace(/\/sdc1/g, '');
55 content = (content + '').replace(/\.bundle/g, '.' + currentTime + '.bundle');
56 return content;
57 }
58 }
Michael Landoed64b5e2017-06-09 03:19:04 +030059 ]),
60 new webpack.DefinePlugin({
61 __DEBUG__: JSON.stringify(true),
62 __ENV__: JSON.stringify('dev'),
63 __HMR__: JSON.stringify('HMR')
64 }),
65 new webpack.HotModuleReplacementPlugin()
66 ]
67
68 };
69
70 return merge(webpackDevConfig, webpackCommonConfig(params));
Michael Lando6e600062017-06-19 19:51:24 +030071}