-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
97 lines (93 loc) · 2.64 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
// tslint:disable:no-implicit-dependencies
// tslint:disable:import-name
import { AureliaPlugin, ModuleDependenciesPlugin } from "aurelia-webpack-plugin";
import { readFileSync } from "fs";
import HtmlWebpackPlugin from "html-webpack-plugin";
import MonacoWebpackPlugin from "monaco-editor-webpack-plugin";
import * as path from "path";
import * as webpack from "webpack";
const pkg = JSON.parse(readFileSync("package.json", "utf-8"));
const title = "Aurelia Dynamic HTML Plugin";
interface IEnv {
server?: boolean;
production?: boolean;
}
const devBaseUrl: string = "/";
const prodBaseUrl: string = `/${pkg.name}/`;
export default (env: IEnv = {}): webpack.Configuration => {
const alias = {
"bluebird": path.resolve(__dirname, "node_modules/bluebird/js/browser/bluebird.core")
};
return {
mode: "development",
resolve: {
extensions: [".ts", ".js"],
modules: [path.resolve(__dirname, "src"), path.resolve(__dirname, "demo"), "node_modules"],
alias
},
entry: {
app: ["aurelia-bootstrapper"],
vendor: ["bluebird"]
},
output: {
path: path.resolve(__dirname),
publicPath: env.production ? prodBaseUrl : devBaseUrl,
filename: "[name].bundle.js"
},
devtool: "cheap-module-eval-source-map",
devServer: {
historyApiFallback: true,
lazy: false,
open: true
},
module: {
rules: [
{
test: /\.css$/,
use: [{ loader: "style-loader" }, { loader: "css-loader" }],
issuer: [{ not: [{ test: /\.html$/i }] }]
},
{
test: /\.css$/,
use: [{ loader: "css-loader" }],
issuer: [{ test: /\.html$/i }]
},
{
test: /\.html$/,
use: [{ loader: "html-loader" }]
},
{
test: /\.ts$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
configFile: path.resolve(__dirname, "configs/tsconfig-demo.json")
}
},
{
test: /[\/\\]node_modules[\/\\]bluebird[\/\\].+\.js$/,
use: [{ loader: "expose-loader?Promise" }]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: "demo/index.ejs",
metadata: {
title,
server: env.server,
baseUrl: env.production ? prodBaseUrl : devBaseUrl
}
}),
new AureliaPlugin(),
new webpack.ProvidePlugin({
Promise: "bluebird"
}),
new MonacoWebpackPlugin(),
new webpack.IgnorePlugin(
/^((fs)|(path)|(os)|(crypto)|(source-map-support))$/,
/vs(\/|\\)language(\/|\\)typescript(\/|\\)lib/
)
]
};
};