This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
83 lines (80 loc) · 3.08 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
const path = require('path');
const webpack = require('webpack');
const { AureliaPlugin, ModuleDependenciesPlugin } = require('aurelia-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const environmentSettings = require("./envsettings.json").ASPNETCORE_ENVIRONMENT;
module.exports = (env, argv) => {
console.log("mode=", environmentSettings);
const isDevBuild = environmentSettings !== "Production";
const cssLoader = { loader: isDevBuild ? "css-loader" : "css-loader?minimize" };
function resolve(dir) {
return path.join(__dirname, 'wwwroot', dir);
}
return [{
node: {
fs: 'empty'
},
target: "web",
mode: isDevBuild ? "development" : "production",
entry: { app: ['aurelia-bootstrapper', 'bluebird'] },
resolve: {
extensions: ['.ts', '.tsx', '.js'],
modules: ['src', 'node_modules'].map(x => path.resolve(x)),
alias: {}
},
output: {
path: path.join(__dirname, "wwwroot", "dist"),
publicPath: "/dist/",
filename: "[name].js",
chunkFilename: "[name].js"
},
module: {
rules: [
{ test: /\.(woff|woff2)(\?|$)/, loader: "url-loader?limit=1" },
{ test: /\.(png|jpg|jpeg|gif|svg|eot|ttf)(\?|$)/, loader: "url-loader?limit=100000" },
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ test: /\.html$/i, use: "html-loader" },
// use Bluebird as the global Promise implementation:
{ test: /[\/\\]node_modules[\/\\]bluebird[\/\\].+\.js$/, loader: 'expose-loader?Promise' },
{ test: /\.css(\?|$)/, include: [/node_modules/], use: [{ loader: MiniCssExtractPlugin.loader }, cssLoader] },
{ 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: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "all"
}
}
}
},
devtool: isDevBuild ? "source-map" : false,
performance: {
hints: false
},
plugins: [
new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
new webpack.ProvidePlugin({ Promise: "bluebird", $: "jquery", jQuery: "jquery", 'window.jQuery': 'jquery', Popper: ['popper.js', 'default'] }),
new AureliaPlugin({ aureliaApp: 'boot' }),
new ModuleDependenciesPlugin({}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[name].css"
}),
new CopyWebpackPlugin([
{ from: resolve('../static/favicon.ico'), to: resolve('dist/favicon.ico') },
{ from: resolve('../static/loading.css'), to: resolve('dist/loading.css') },
{ from: resolve('../static/webfonts'), to: resolve('dist/webfonts') }
], { debug: 'info' })
]
}];
}