forked from mattlewis92/angular-text-input-autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
83 lines (81 loc) · 2.27 KB
/
webpack.config.ts
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
import webpack from 'webpack';
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { getIfUtils, removeEmpty } from 'webpack-config-utils';
import { AngularCompilerPlugin } from '@ngtools/webpack';
import OfflinePlugin from 'offline-plugin';
export default (environment = 'development') => {
const { ifProduction, ifDevelopment } = getIfUtils(environment);
return {
mode: environment,
devtool: ifProduction('source-map', 'eval'),
entry: path.join(__dirname, 'demo', 'entry.ts'),
output: {
path: __dirname,
filename: ifProduction('[name]-[chunkhash].js', '[name].js')
},
module: {
rules: removeEmpty([
ifDevelopment({
test: /\.ts$/,
loader: 'tslint-loader',
exclude: /node_modules/,
enforce: 'pre'
}),
ifDevelopment(
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
transpileOnly: true
}
},
{
test: /\.ts$/,
loader: '@ngtools/webpack'
}
),
{
test: /node_modules\/@angular\/core\/.+\/core\.js$/,
parser: {
system: true // disable `System.import() is deprecated and will be removed soon. Use import() instead.` warning
}
}
])
},
resolve: {
extensions: ['.ts', '.js']
},
devServer: {
port: 8000,
inline: true,
hot: true,
historyApiFallback: true,
overlay: true
},
plugins: removeEmpty([
ifProduction(
new AngularCompilerPlugin({
tsConfigPath: './tsconfig-demo.json'
})
),
ifDevelopment(new webpack.HotModuleReplacementPlugin()),
ifDevelopment(
new ForkTsCheckerWebpackPlugin({
watch: ['./src', './demo'],
formatter: 'codeframe'
})
),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)fesm5/,
path.join(__dirname, 'src')
),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'demo', 'index.ejs')
}),
ifProduction(new OfflinePlugin())
])
};
};