This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathserve.webpack.config.js
97 lines (89 loc) · 2.63 KB
/
serve.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
/*jslint node: true */
'use strict';
const fs = require('fs');
const path = require('path');
const webpackMerge = require('webpack-merge');
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin');
const skyPagesConfigUtil = require('../sky-pages/sky-pages.config');
const browser = require('../../cli/utils/browser');
/**
* Returns the default webpackConfig.
* @name getDefaultWebpackConfig
* @returns {WebpackConfig} webpackConfig
*/
function getWebpackConfig(argv, skyPagesConfig) {
/**
* Opens the host service url.
* @name WebpackPluginDone
*/
function WebpackPluginDone() {
let launched = false;
this.plugin('done', (stats) => {
if (!launched) {
launched = true;
browser(argv, skyPagesConfig, stats, this.options.devServer.port);
}
});
}
const common = require('./common.webpack.config').getWebpackConfig(skyPagesConfig, argv);
return webpackMerge(common, {
watch: true,
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'awesome-typescript-loader',
options: {
// Ignore the "Cannot find module" error that occurs when referencing
// an aliased file. Webpack will still throw an error when a module
// cannot be resolved via a file path or alias.
ignoreDiagnostics: [2307],
transpileOnly: true,
silent: true
}
},
{
loader: 'angular2-template-loader'
}
],
exclude: [/\.e2e\.ts$/]
}
]
},
devServer: {
compress: true,
inline: true,
stats: false,
hot: argv.hmr,
contentBase: path.join(process.cwd(), 'src', 'app'),
headers: {
'Access-Control-Allow-Origin': '*'
},
historyApiFallback: {
index: skyPagesConfigUtil.getAppBase(skyPagesConfig)
},
https: {
key: fs.readFileSync(path.join(__dirname, '../../ssl/server.key')),
cert: fs.readFileSync(path.join(__dirname, '../../ssl/server.crt'))
},
publicPath: skyPagesConfigUtil.getAppBase(skyPagesConfig)
},
devtool: 'source-map',
plugins: [
new NamedModulesPlugin(),
WebpackPluginDone,
new LoaderOptionsPlugin({
context: __dirname,
debug: true
}),
new HotModuleReplacementPlugin()
]
});
}
module.exports = {
getWebpackConfig: getWebpackConfig
};