Skip to content

Commit

Permalink
prod intg build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Moumita Mandal committed Aug 23, 2021
1 parent a70e23d commit 0c7aae7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"size-build": "npm run buildProdBrowser",
"size": "npm run size-build && size-limit",
"changelog": "auto-changelog -p -t keepachangelog -u true -l false --sort-commits date-desc ",
"buildDevIntegration": "NODE_ENV=false uglify=false INTG_NAME=AdobeAnalytics rollup --config rollup.intgConfig.js"
"buildDevIntegration": "NODE_ENV=false uglify=false INTG_NAME=AdobeAnalytics rollup --config rollup.intgConfig.js",
"buildProdIntegration": "NODE_ENV=false ENV=prod uglify=true INTG_NAME=Keen rollup --config rollup.intgConfig.js"
},
"pre-commit": [
"prodTest",
Expand Down
67 changes: 55 additions & 12 deletions rollup.intgConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,64 @@ import gzipPlugin from "rollup-plugin-gzip";
import brotli from "rollup-plugin-brotli";
import visualizer from "rollup-plugin-visualizer";
import * as webPackage from "./package.json";
import * as npmPackage from "./dist/rudder-sdk-js/package.json";

const distFileName = `dist/integrations/${process.env.INTG_NAME}.js`;
const { version } = webPackage;
const moduleType = "web";
let distFileName = "";
let { version } = webPackage;
let moduleType = "web";

switch (process.env.ENV) {
case "prod":
switch (process.env.ENC) {
case "gzip":
if (process.env.PROD_DEBUG_INLINE === "true") {
distFileName = `dist/integrations/${process.env.INTG_NAME}-map.min.gzip.js`;
} else {
distFileName = `dist/integrations/${process.env.INTG_NAME}.min.gzip.js`;
}
break;
case "br":
if (process.env.PROD_DEBUG_INLINE === "true") {
distFileName = `dist/integrations/${process.env.INTG_NAME}-map.min.br.js`;
} else {
distFileName = `dist/integrations/${process.env.INTG_NAME}.min.br.js`;
}
break;
default:
if (process.env.PROD_DEBUG_INLINE === "true") {
distFileName = `dist/integrations/${process.env.INTG_NAME}-map.min.js`;
} else {
distFileName = `dist/integrations/${process.env.INTG_NAME}.min.js`;
}
break;
}
break;
default:
distFileName = `dist/integrations/${process.env.INTG_NAME}.js`;
break;
}

const outputFiles = [];
outputFiles.push({
file: distFileName,
format: "iife",
name: `${process.env.INTG_NAME}`,
sourcemap:
process.env.PROD_DEBUG_INLINE === "true"
? "inline"
: !!process.env.PROD_DEBUG,
});

if (process.env.NPM === "true") {
outputFiles.push({
file: `dist/integrations/${process.env.INTG_NAME}/index.js`,
format: "umd",
name: `${process.env.INTG_NAME}`,
});
version = npmPackage.version;
moduleType = "npm";
} else {
outputFiles.push({
file: distFileName,
format: "iife",
name: `${process.env.INTG_NAME}`,
sourcemap:
process.env.PROD_DEBUG_INLINE === "true"
? "inline"
: !!process.env.PROD_DEBUG,
});
}

export default {
input: `./integrations/${process.env.INTG_NAME}/index.js`,
Expand Down

0 comments on commit 0c7aae7

Please sign in to comment.