forked from aadzl/angular-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
122 lines (119 loc) · 3.49 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
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
import * as path from 'path';
import * as webpack from 'webpack';
import * as ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import * as StyleLintPlugin from 'stylelint-webpack-plugin';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import { getIfUtils, removeEmpty } from 'webpack-config-utils';
import { AngularCompilerPlugin } from '@ngtools/webpack';
import * as OfflinePlugin from 'offline-plugin';
import * as FilterWarningsPlugin from 'webpack-filter-warnings-plugin';
export default (env = 'development') => {
const { ifProduction, ifDevelopment } = getIfUtils(env);
return {
devtool: ifProduction('source-map', 'eval'),
entry: path.join(__dirname, 'demos', 'entry.ts'),
output: {
filename: ifProduction('[name]-[chunkhash].js', '[name].js')
},
module: {
rules: removeEmpty([ifDevelopment({
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
exclude: /node_modules/
}), ifDevelopment({
test: /\.ts$/,
use: [{
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
module: 'esnext'
}
}
}, {
loader: 'angular2-template-loader'
}, {
loader: 'angular-router-loader'
}],
exclude: /node_modules/
}, {
test: /\.ts$/,
loader: '@ngtools/webpack'
}), {
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
}, {
test: /(node_modules).+\.css$/,
loader: 'style-loader!css-loader'
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff'
}
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}, {
test: /demos[\/\\].+\.(css|html)$/,
loader: 'raw-loader'
}, {
test: /\.ejs$/,
loader: 'ejs-compiled-loader'
}])
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'angular-calendar$': path.resolve(__dirname, 'src/index.ts')
}
},
devServer: {
port: 8000,
inline: true,
hot: true,
historyApiFallback: true,
overlay: true
},
plugins: removeEmpty([
new FilterWarningsPlugin({
exclude: /export '\w+' was not found in 'calendar-utils'/
}),
ifDevelopment(new ForkTsCheckerWebpackPlugin({
watch: ['./src', './demos'],
formatter: 'codeframe'
})),
ifDevelopment(new webpack.HotModuleReplacementPlugin()),
ifProduction(new webpack.optimize.ModuleConcatenationPlugin()),
ifProduction(new AngularCompilerPlugin({
tsConfigPath: './tsconfig-demos.json',
sourceMap: true
})),
new webpack.DefinePlugin({
ENV: JSON.stringify(env)
}),
ifProduction(new webpack.optimize.UglifyJsPlugin({
sourceMap: true
})),
ifDevelopment(new StyleLintPlugin({
syntax: 'scss',
context: 'scss'
})),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)esm5/,
__dirname + '/demos'
),
new webpack.optimize.CommonsChunkPlugin({
name: 'main',
async: true,
minChunks: 2
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'demos', 'index.ejs')
}),
ifProduction(new OfflinePlugin())
])
}
};