This repository has been archived by the owner on Jun 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
webpack.common.js
74 lines (71 loc) · 2.38 KB
/
webpack.common.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
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractSass = new ExtractTextPlugin({ filename: "[name].css" });
const commonConfig = {
output: { path: path.resolve(__dirname, "app"), filename: "[name].js" },
devtool: "cheap-module-eval-source-map",
mode: "development",
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"],
modules: [
path.resolve(__dirname, "src", "renderer"),
path.resolve(__dirname, "src", "main"),
path.resolve(__dirname, "src", "common"),
path.resolve(__dirname, "src", "interfaces"),
path.resolve(__dirname, "test"),
"node_modules"
]
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: "awesome-typescript-loader"
},
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
{
test: /\.scss$/,
use: extractSass.extract({
use: [
{
loader: "css-loader",
options: { minimize: true }
},
{
loader: "sass-loader",
options: { includePaths: ["node_modules"] }
}
]
})
},
{
test: /\.css$/,
use: extractSass.extract({ use: [{ loader: "css-loader" }] })
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
}
]
},
node: { fs: "empty", __dirname: false },
externals: [
nodeExternals(),
(ctx, req, done) => (/^node-pty$/.test(req) ? done(null, `commonjs ${req}`) : done())
]
};
module.exports = [
Object.assign(
{
target: "electron-main",
entry: { main: "./src/main/index.ts" }
}, commonConfig),
Object.assign(
{
target: "electron-renderer",
entry: { renderer: "./src/renderer/index.tsx" },
plugins: [extractSass]
}, commonConfig)
];