-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
95 lines (88 loc) · 2.71 KB
/
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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ngToolsWebpack = require('@ngtools/webpack');
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: {
'polyfills': './src/polyfills.ts',
'app': ['./src/main.ts', './src/styles.css']
},
resolve: {
extensions: ['.ts', '.js', '.css'],
modules: [
'./node_modules'
]
},
mode: 'production',
devServer: {
contentBase: './dist',
hot: false,
port: 8080,
watchContentBase: true,
historyApiFallback: true
},
output: {
path: path.resolve('dist'),
filename: '[name].js',
publicPath: '/',
chunkFilename: '[id].chunk.js'
},
module: {
rules: [
{
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
loader: '@ngtools/webpack'
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot)$/,
loader: 'file-loader?name=assets/[name].[hash].[ext]'
},
{
test: /\.css$/,
exclude: path.resolve('./src/app'),//For src/styles.css
use: [
//Use to-string-loader as ExtractTextPlugin in not compatible with webpack 4 and
//MiniCssExtractPlugin is giving Error: Expected 'styles' to be an array of strings
//'to-string-loader',//Now no error so commenting it
MiniCssExtractPlugin.loader,
'css-loader'
]
},
{
test: /\.css$/,
include: path.resolve('./src/app'),//For src/app/**/*.css
loader: 'raw-loader'
}
]
},
plugins: [
new WebpackCleanupPlugin(),
new ngToolsWebpack.AngularCompilerPlugin({
tsConfigPath: 'tsconfig.json',
mainPath: 'src/main.ts',
entryModule: 'src/app/app.module#AppModule',
skipCodeGeneration: false
}),
new MiniCssExtractPlugin({
filename: "[name].css"
}),
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./dll/vendor-manifest.json')
}),
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new AddAssetHtmlPlugin({
filepath: path.resolve('./dll/vendor.dll.js')
})
]
}