Skip to content

Commit

Permalink
Accept customized plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jalal246 committed Feb 24, 2020
1 parent 5aadf22 commit badb5fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/config/input/getInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ function genInput({
BUILD_FORMAT
});

const plugins = getPlugins({ presets, IS_SILENT, BUILD_FORMAT, BABEL_ENV });
const plugins = getPlugins({
presets,
IS_SILENT,
BUILD_FORMAT,
BABEL_ENV,
...advancedOpt
});

return {
input: sourcePath,
external,
plugins,
...advancedOpt
plugins
};
}

Expand Down
12 changes: 10 additions & 2 deletions src/config/input/getInputPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ const { UMD, CJS, ES, PROD } = require("../../constants");
* @param {string} BABEL_ENV
* @returns {Array} plugins
*/
function getPlugins({ presets, IS_SILENT, BUILD_FORMAT, BABEL_ENV }) {
function getPlugins({
presets,
IS_SILENT,
BUILD_FORMAT,
BABEL_ENV,
...advancedOpt
}) {
const plugins = [
/**
* Beeps when a build ends with errors.
Expand Down Expand Up @@ -53,7 +59,9 @@ function getPlugins({ presets, IS_SILENT, BUILD_FORMAT, BABEL_ENV }) {
/**
* Replaces strings in files while bundling.
*/
replace({ "process.env.NODE_ENV": JSON.stringify("BABEL_ENV") })
replace({ "process.env.NODE_ENV": JSON.stringify("BABEL_ENV") }),

...advancedOpt
];

if (!IS_SILENT) {
Expand Down
10 changes: 6 additions & 4 deletions src/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async function build(inputOptions, outputOptions, isWatch, onWatch) {
}
}

async function bundlePackage({ isProd, format, camelizedName, pkg }) {
async function bundlePackage({ isProd, format, camelizedName, pkg, plugins }) {
const BUILD_FORMAT = format;
const BABEL_ENV = `${isProd ? PROD : DEV}`;

Expand All @@ -108,7 +108,8 @@ async function bundlePackage({ isProd, format, camelizedName, pkg }) {
dependencies,
sourcePath,
presets,
flags
flags,
plugins
});

const output = getOutput({
Expand All @@ -121,7 +122,7 @@ async function bundlePackage({ isProd, format, camelizedName, pkg }) {
await build(input, output);
}

async function start() {
async function start(plugins) {
const sortedPackages = initBuild(buildName, listOfPackages);

const bundleOpt = getBundleOpt();
Expand All @@ -139,7 +140,8 @@ async function start() {
isProd,
format,
camelizedName,
pkg
pkg,
plugins
});
});
});
Expand Down

0 comments on commit badb5fd

Please sign in to comment.