forked from carbon-design-system/carbon-components-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.build.js
76 lines (74 loc) · 1.78 KB
/
webpack.build.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
function angularExt(lib) {
let ns = `@angular/${lib}`;
return {root: ["ng", lib], commonjs: ns, commonjs2: ns, amd: ns};
}
function rxjsExternal(context, request, cb) {
if (request.match(/^rxjs(\/|$)/)) {
const pathParts = request.split("/");
return cb(null, {root: pathParts, commonjs: request, commonjs2: request, amd: request});
}
cb();
}
module.exports = [{
mode: "production",
devtool: "source-map",
entry: {
carbonAngular: "./src/index.ts",
},
output: {
path: __dirname + "/dist/bundle",
filename: "carbon-angular.umd.js",
library: "carbonAngular",
libraryTarget: "umd"
},
externals: [
{
"@angular/core": angularExt("core"),
"@angular/common": angularExt("common"),
"@angular/platform-browser": {
root: ["ng", "platformBrowser"],
commonjs: "@angular/platform-browser",
commonjs2: "@angular/platform-browser",
amd: "@angular/platform-browser"
},
"@angular/platform-browser/animations": {
root: ["ng", "platformBrowser", "animations"],
commonjs: "@angular/platform-browser/animations",
commonjs2: "@angular/platform-browser/animations",
amd: "@angular/platform-browser/animations"
},
"@angular/forms": angularExt("forms"),
"@angular/compiler": angularExt("compiler"),
"@angular/http": angularExt("http"),
},
rxjsExternal
],
module: {
rules: [
{
test: /\.ts$/,
loaders: ["ts-loader", "tslint-loader"]
},
{
test: /\.html$/,
loader: "html-loader"
},
{
test: /\.css$/,
loader: ["raw-loader", "postcss-loader"]
},
{
test: /\.scss$/,
loaders: ["raw-loader", "postcss-loader", "sass-loader"]
},
{
test : /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
loader : "file-loader"
}
]
},
resolve: {
extensions: [".ts", ".js", ".json"]
},
plugins: [],
}];