This repository has been archived by the owner on Aug 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
61 lines (60 loc) · 1.58 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
var path = require("path");
var webpack = require("webpack");
var NotifierPlugin = require("webpack-notifier");
var CleanWebpackPlugin = require("clean-webpack-plugin");
var srcDir = path.resolve(__dirname, "src");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var environment = process.env.NODE_ENV || "development";
module.exports = {
context: path.join(__dirname, "src"),
entry: {
index: ["./index.ts"]
},
output: {
path: path.join(__dirname, "build"),
filename: "[name].js"
},
resolve: {
// resolve absolute module names relative to node_modules folder
root: [path.join(__dirname, "node_modules")],
// file extensions to resolve
extensions: ["", ".ts", ".tsx", ".js", ".json"]
},
module: {
preLoaders: [{
test: /\.ts$/,
include: [srcDir],
loader: "tslint-loader"
}],
loaders: [{
// transpile with typescript
test: /\.ts$/,
include: [srcDir],
loader: "ts-loader"
}, {
// copy resources as separate files
test: /\.png|\.jpg|\.gif|\.ttf|\.svg|\.ico/,
loader: "file?name=[path][name].[ext]"
}]
},
plugins: [
// clean build folder before build
new CleanWebpackPlugin(["build"],{
root: __dirname
}),
// show desktop notification
new NotifierPlugin({
contentImage: path.join(__dirname, "logo.png"),
alwaysNotify: true
}),
new HtmlWebpackPlugin({
template: "index.html",
favicon: "../logo.png",
chunks: ["index"]
})
],
// optimize flag
debug: environment === "development",
// source maps flag
devtool: environment === "development" ? "sourcemap" : undefined
};