forked from mohitbagra/azure-devops-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
89 lines (83 loc) · 2.69 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
const path = require("path");
const webpack = require("webpack");
const merge = require("webpack-merge");
const { existsSync } = require("fs");
const appName = require("./configs/App");
if (!appName) {
throw "no app name provided";
}
console.log(`Selected app: ${appName}`);
let appConfig;
const appPath = path.resolve(__dirname, `src/Apps/${appName}`);
if (existsSync(appPath)) {
console.log(`App "${appName}" found.`);
const configPath = path.resolve(__dirname, `src/Apps/${appName}/webpack.config.js`);
if (existsSync(configPath)) {
appConfig = require(configPath);
} else {
throw `No config found for App "${appName}".`;
}
} else {
throw `App "${appName}" not found.`;
}
module.exports = (env, argv) => {
const plugins =
argv.mode === "production"
? [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production")
})
]
: [];
const defaultConfig = {
target: "web",
output: {
publicPath: argv.mode === "production" ? "../" : "/",
filename: "scripts/[name].js",
chunkFilename: "scripts/[name].chunk.js"
},
resolve: {
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"],
moduleExtensions: ["-loader"],
alias: {
OfficeFabric: path.resolve(__dirname, "node_modules/office-ui-fabric-react/lib"),
Common: path.resolve(__dirname, "src/Common")
}
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader"
},
{
test: /\.scss$/,
use: [
"style-loader",
"css-loader",
{
loader: "sass-loader",
options: {
includePaths: [path.join(__dirname, "src/Common")]
}
}
]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.woff$/,
use: [
{
loader: "base64-inline-loader"
}
]
}
]
},
plugins: plugins
};
return merge(defaultConfig, appConfig);
};