UNPKG

2.01 kBJavaScriptView Raw
1const HardSourceWebpackPlugin = require("hard-source-webpack-plugin"),
2 appDir = process.cwd(),
3 path = require("path"),
4 webpack = require("webpack"),
5 yn = require("yn");
6
7const assetsPath = path.join(appDir, process.env.CANON_STATIC_FOLDER || "static", "assets");
8const publicPath = "/assets/";
9const appPath = path.join(appDir, "app");
10
11const loaderPath = require.resolve("./config/loaders");
12delete require.cache[loaderPath];
13const commonLoaders = require(loaderPath);
14
15process.traceDeprecation = true;
16
17module.exports = {
18 devtool: "eval",
19 name: "client",
20 mode: "development",
21 context: path.join(__dirname, "../src"),
22 entry: {
23 app: [
24 "@babel/polyfill",
25 "react-hot-loader/patch",
26 "webpack-hot-middleware/client",
27 "./client"
28 ]
29 },
30 output: {
31 path: assetsPath,
32 filename: "[name].js",
33 publicPath
34 },
35 module: {
36 rules: commonLoaders({build: "client"})
37 },
38 resolve: {
39 modules: [
40 path.join(appDir, "node_modules"),
41 appDir,
42 appPath,
43 path.join(__dirname, "../src"),
44 path.join(__dirname, "../node_modules")
45 ],
46 extensions: [".js", ".jsx", ".css"]
47 },
48 plugins: [
49 new webpack.ProgressPlugin({
50 activeModules: false,
51 entries: false,
52 modules: true
53 }),
54 new HardSourceWebpackPlugin({
55 cacheDirectory: path.join(appDir, "node_modules/.cache/hard-source/[confighash]"),
56 environmentHash: {
57 root: appDir,
58 directories: [],
59 files: ["package-lock.json", "yarn.lock", "app/style.yml", ".env", ".envrc"]
60 },
61 info: {level: "error"}
62 }),
63 new webpack.HotModuleReplacementPlugin(),
64 new webpack.DefinePlugin(Object.keys(process.env)
65 .filter(e => e.startsWith("CANON_CONST_"))
66 .reduce((d, k) => {
67 d[`__${k.replace("CANON_CONST_", "")}__`] = JSON.stringify(process.env[k]);
68 return d;
69 }, {__DEV__: true, __SERVER__: false, __LOGREDUX__: yn(process.env.CANON_LOGREDUX || true)}))
70 ]
71};