forked from saleor/saleor-storefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
27 lines (21 loc) · 861 Bytes
/
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
const path = require("path");
const merge = require("webpack-merge");
require("dotenv").config();
const baseConfig = require("./config/webpack/config.base");
const devConfig = require("./config/webpack/config.dev");
const prodConfig = require("./config/webpack/config.prod");
const workerConfig = require("./config/webpack/config.worker");
const sourceDir = path.join(__dirname, "./src");
const distDir = path.join(__dirname, "./dist");
module.exports = (env, argv) => {
const devMode = argv.mode !== "production";
const sw = !!argv["service-worker"];
const paths = { sourceDir, distDir };
const base = baseConfig(paths);
const worker = workerConfig(paths);
const dev = sw
? merge(base, worker, devConfig(paths))
: merge(base, devConfig(paths));
const prod = merge(base, worker, prodConfig(paths));
return devMode ? dev : prod;
};