forked from BloomBooks/LegacyBloomPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
98 lines (89 loc) · 2.5 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
96
97
98
var path = require("path");
var merge = require("webpack-merge");
var TARGET = process.env.npm_lifecycle_event;
var webpack = require("webpack");
var common_player_bits = {
context: __dirname,
entry: "./src/app.ts",
output: {
path: path.join(__dirname, "./output"),
filename: "legacyBloomPlayer.js"
},
resolve: {
root: ["."],
modulesDirectories: [path.resolve(__dirname, "node_modules")],
extensions: ["", ".js", ".ts", ".tsx"]
},
module: {
preLoaders: [{ test: /\.ts$/, loader: "tslint" }],
loaders: [
{ test: /\.ts(x?)$/, loader: "ts-loader" },
{
test: /\.less$/,
loaders: ["style-loader", "css-loader", "less-loader"]
},
//{ test: /\.(svg|png)$/, loader: 'file', include: path.join(__dirname, "./assets")}
{
test: /\.(svg|png)$/,
loader: "url-loader",
include: path.join(__dirname, "./assets")
}
]
}
};
var common_page_player_bits = {
context: __dirname,
entry: "./src/pagePlayer/app.ts",
output: {
path: path.join(__dirname, "./output"),
filename: "bloomPagePlayer.js",
libraryTarget: "var",
library: "Root"
},
resolve: {
root: ["."],
modulesDirectories: [path.resolve(__dirname, "node_modules")],
extensions: ["", ".js", ".ts", ".tsx"]
},
module: {
preLoaders: [{ test: /\.ts$/, loader: "tslint" }],
loaders: [
{ test: /\.ts(x?)$/, loader: "ts-loader" },
{
test: /\.less$/,
loaders: ["style-loader", "css-loader", "less-loader"]
},
//{ test: /\.(svg|png)$/, loader: 'file', include: path.join(__dirname, "./assets")}
{
test: /\.(svg|png)$/,
loader: "url-loader",
include: path.join(__dirname, "./assets")
}
]
}
};
var dev_bits = {
//devtool: 'source-map', // cannot cache SourceMaps for modules and need to regenerate complete SourceMap for the chunk. It’s something for production.
devtool: "#cheap-module-eval-source-map" //the 'cheap' here means rows only, not columns
};
var production_bits = {
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
};
//we get this if the build is run via "npm run build:prod"
if (process.env.npm_lifecycle_event == "build:prod") {
module.exports = [
merge(common_player_bits, production_bits),
merge(common_page_player_bits, production_bits)
];
} else {
module.exports = [
merge(common_player_bits, dev_bits),
merge(common_page_player_bits, dev_bits)
];
}