Skip to content

Commit

Permalink
feat: copy config to webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
subhendukundu committed Feb 15, 2021
1 parent c482662 commit 4193a62
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions configs/flarect.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
14 changes: 14 additions & 0 deletions configs/webpack.worker.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { flareactConfig } = require("./utils");
const defaultLoaders = require("./loaders");
const { nanoid } = require("nanoid");
const fs = require("fs");
const { CONFIG_FILE } = require("../src/constants");

const dev = !!process.env.WORKER_DEV;
const isServer = true;
Expand Down Expand Up @@ -59,5 +60,18 @@ module.exports = function (env, argv) {
});
}

if (flareact.redirects) {
config.plugins.push(
new CopyPlugin(
[
{
from: `${projectDir}/${CONFIG_FILE}`,
to: `./${CONFIG_FILE}`,
},
],
),
);
}

return config;
};
7 changes: 5 additions & 2 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export const TEMPORARY_REDIRECT_STATUS = 307;
export const PERMANENT_REDIRECT_STATUS = 308;
module.exports = {
TEMPORARY_REDIRECT_STATUS: 307,
PERMANENT_REDIRECT_STATUS: 308,
CONFIG_FILE: 'flareact.config.js'
};
5 changes: 1 addition & 4 deletions src/worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import {
TEMPORARY_REDIRECT_STATUS,
} from "../constants";
import { checkRedirectUrl } from "./redirects";
import { flareactConfig } from "../../configs/utils";

const projectDir = process.cwd();
const config = flareactConfig(projectDir);
import config from "../../configs/flarect.config";

const dev =
(typeof DEV !== "undefined" && !!DEV) ||
Expand Down

0 comments on commit 4193a62

Please sign in to comment.