This repository has been archived by the owner on Sep 10, 2023. It is now read-only.
forked from MaximBalaganskiy/AureliaDotnetTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
80 lines (76 loc) · 3.24 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
const path = require("path");
const webpack = require("webpack");
const { AureliaPlugin, ModuleDependenciesPlugin, GlobDependenciesPlugin } = require("aurelia-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const extractCSS = new ExtractTextPlugin("vendor.css");
const bundleOutputDir = "./wwwroot/dist";
module.exports = (env, argv) => {
if ((!argv || !argv.mode) && process.env.ASPNETCORE_ENVIRONMENT === "Development") {
argv = { mode: "development" };
}
console.log("mode=", argv.mode);
const isDevBuild = argv.mode !== "production";
const cssLoader = { loader: isDevBuild ? "css-loader" : "css-loader?minimize" };
return [{
target: "web",
mode: isDevBuild ? "development" : "production",
entry: { "app": ["es6-promise/auto", "aurelia-bootstrapper"] },
resolve: {
extensions: [".ts", ".js"],
modules: ["ClientApp", "node_modules"]
},
output: {
path: path.resolve(bundleOutputDir),
publicPath: "/dist/",
filename: "[name].js",
chunkFilename: "[name].js"
},
module: {
rules: [
{ test: /\.(woff|woff2)(\?|$)/, loader: "url-loader?limit=1" },
{ test: /\.(png|eot|ttf|svg)(\?|$)/, loader: "url-loader?limit=100000" },
{ test: /\.ts$/i, include: [/ClientApp/, /node_modules/], use: "awesome-typescript-loader" },
{ test: /\.html$/i, use: "html-loader" },
{ test: /\.css(\?|$)/, include: [/node_modules/], loader: extractCSS.extract([isDevBuild ? 'css-loader' : 'css-loader?minimize']) },
{ test: /\.css$/i, exclude: [/node_modules/], issuer: /\.html$/i, use: cssLoader },
{ test: /\.css$/i, exclude: [/node_modules/], issuer: [{ not: [{ test: /\.html$/i }] }], use: ["style-loader", cssLoader] },
{ test: /\.scss$/i, issuer: /(\.html|empty-entry\.js)$/i, use: [cssLoader, "sass-loader"] },
{ test: /\.scss$/i, issuer: /\.ts$/i, use: ["style-loader", cssLoader, "sass-loader"] }
]
},
optimization: {
splitChunks: {
chunks: "all",
// uncomment the following to create a separate bundle for each npm module
/* maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
// npm package names are URL-safe, but some servers don't like @ symbols
return `npm.${packageName.replace('@', '')}`;
}
}
}*/
}
},
devtool: isDevBuild ? "source-map" : false,
performance: {
hints: false
},
plugins: [
new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "window.jQuery": "jquery" }),
new HtmlWebpackPlugin({ template: 'Views/Shared/_LayoutTemplate.cshtml', filename: "../../Views/Shared/_Layout.cshtml", inject: false, metadata: {}, alwaysWriteToDisk: true }),
new AureliaPlugin({ aureliaApp: "boot" }),
new GlobDependenciesPlugin({ "boot": ["ClientApp/**/*.{ts,html}"] }),
new ModuleDependenciesPlugin({}),
extractCSS
]
}];
};