-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
96 lines (85 loc) · 2 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
// include libs
const path = require("path");
const fs = require("fs");
// initialise the copy-webpack-plugin so that the task.json files are
// copied into the dist folder for each task
const copyWebpackPlugin = require("copy-webpack-plugin");
// build up the entries to be compiled
const entries = {};
const srcDir = path.join(__dirname, "src");
fs.readdirSync(srcDir)
.filter(dir => fs.statSync(path.join(srcDir, dir)).isDirectory() && dir != "common")
.forEach(dir => (entries[dir] = "./" + path.join("src", dir, dir)))
var config = {
devtool: "inline-source-map",
devServer: {
https: true,
port: 3000,
contentBase: path.join(__dirname, "build", "preview")
},
entry: entries,
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node-modules/
}
]
},
output: {
publicPath: "/dist/",
filename: "[name]/[name].js"
},
plugins: [
new copyWebpackPlugin({
patterns: [
{
from: "**/task.json",
context: "src"
},
{
from: "**/icon.png",
context: "src"
},
{
from: "conf/*.json",
to: "../.."
},
{
from: "common",
to: "common",
context: "src"
}
]
})
],
resolve: {
extensions: [
".ts",
".js",
".json"
]
},
target: 'node'
};
module.exports = (env, argv) => {
// function variables
// - set the type the build
var buildType = "preview";
// - define buildPath
var buildPath;
// if the DEV env var is true, then set the development path to the dev build
if (argv.mode == "development" && process.env.dev == "true") {
buildType = "dev"
}
// if the mode is production set the buildType
if (argv.mode == "production") {
buildType = "release";
}
// set the build path
buildPath = path.join(__dirname, "build", buildType, "tasks");
console.log(buildPath);
config.output.path = buildPath;
return config;
};