forked from edrlab/thorium-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.main.js
64 lines (54 loc) · 1.77 KB
/
webpack.config.main.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
const path = require("path");
const webpack = require("webpack");
// Default values for DEV environment
let nodeEnv = process.env.NODE_ENV || "DEV";
let pouchDbAdapterName = (nodeEnv === "DEV") ? "jsondown" : "leveldb";
let pouchDbAdapterPackage = (nodeEnv === "DEV") ?
"readium-desktop/pouchdb/jsondown-adapter" : "pouchdb-adapter-leveldb";
let rendererBaseUrl = "file://";
if (nodeEnv === "DEV") {
rendererBaseUrl = "http://localhost:8080/dist/";
}
let definePlugin = new webpack.DefinePlugin({
__NODE_ENV__: JSON.stringify(nodeEnv),
__POUCHDB_ADAPTER_NAME__: JSON.stringify(pouchDbAdapterName),
__POUCHDB_ADAPTER_PACKAGE__: JSON.stringify(pouchDbAdapterPackage),
__RENDERER_BASE_URL__: JSON.stringify(rendererBaseUrl),
});
let config = Object.assign({}, {
entry: "./src/main.ts",
name: "main",
output: {
filename: "main.js",
path: path.join(__dirname, "dist"),
// https://github.com/webpack/webpack/issues/1114
libraryTarget: "commonjs2",
},
target: "electron-main",
node: {
__dirname: false,
__filename: false,
},
// Webpack is unable to manage native modules
externals: {
"leveldown": "leveldown",
},
resolve: {
// Add '.ts' as resolvable extensions.
extensions: [".ts", ".js", ".node"],
alias: {
"readium-desktop": path.resolve(__dirname, "src"),
},
},
module: {
loaders: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loaders: ["awesome-typescript-loader"] },
{ test: /\.node$/, loaders: ["node-loader"] },
],
},
plugins: [
definePlugin,
],
});
module.exports = config;