Skip to content

Commit

Permalink
archetype-react-app: [patch] use babel to optimize modules for PROD
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Jun 17, 2017
1 parent 829ff16 commit 6a85b4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 36 deletions.
6 changes: 2 additions & 4 deletions packages/electrode-archetype-react-app-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"babel-eslint": "^7.0.0",
"babel-loader": "^7.0.0",
"babel-plugin-lodash": "^3.1.3",
"babel-plugin-minify-dead-code-elimination": "^0.1.7",
"babel-plugin-react-intl": "^2.1.2",
"babel-plugin-transform-node-env-inline": "^0.1.1",
"babel-plugin-transform-object-rest-spread": "^6.3.13",
"babel-plugin-transform-react-constant-elements": "^6.5.0",
"babel-plugin-transform-react-inline-elements": "^6.6.5",
Expand Down Expand Up @@ -56,9 +58,6 @@
"fs-extra": "^0.26.5",
"glob": "^7.0.6",
"gulp": "^3.9.1",
"gulp-envify": "^1.0.0",
"gulp-filter": "^4.0.0",
"gulp-uglify": "^2.0.0",
"isomorphic-loader": "^1.0.0",
"isparta-loader": "^2.0.0",
"istanbul": "^0.3.18",
Expand Down Expand Up @@ -106,7 +105,6 @@
"stylus-relative-loader": "^3.0.0",
"sw-precache": "^4.3.0",
"sw-toolbox": "^3.4.0",
"uglify-js": "^2.7.4",
"url-loader": "^0.5.6",
"web-app-manifest-loader": "^0.1.1",
"webpack": "^2.2.0",
Expand Down
43 changes: 11 additions & 32 deletions packages/electrode-archetype-react-app/arch-gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const gulpHelper = devRequire("electrode-gulp-helper");
const shell = gulpHelper.shell;
const config = archetype.config;
const mkdirp = devRequire("mkdirp");
const envify = devRequire("gulp-envify");
const uglify = devRequire("gulp-uglify");
const filter = devRequire("gulp-filter");

const penthouse = archetype.devRequire("penthouse");
const CleanCSS = archetype.devRequire("clean-css");
Expand Down Expand Up @@ -206,7 +203,7 @@ function inlineCriticalCSS() {
*
*/

function makeTasks(gulp) {
function makeTasks() {
const checkFrontendCov = minimum => {
if (typeof minimum === "string") {
minimum += ".";
Expand All @@ -224,34 +221,16 @@ function makeTasks(gulp) {
assert(shell.test("-d", modulePath), `${modulePath} is not a directory`);
createGitIgnoreDir(Path.resolve(archetype.prodModulesDir), "Electrode production modules dir");
const prodPath = Path.join(archetype.prodModulesDir, module);
return new Promise((resolve, reject) =>
gulp
.src(`${modulePath}/**/*.js`)
.pipe(filter(["**", "!**/dist/**"]))
.pipe(
envify({
NODE_ENV: "production"
})
)
.pipe(
uglify({
compress: {
sequences: false,
dead_code: true,
drop_debugger: true
},
output: {
beautify: false,
comments: false,
bracketize: true
}
})
)
.pipe(gulp.dest(prodPath))
.on("error", reject)
.on("end", resolve)
).then(() => {
shell.cp(Path.join(modulePath, "package.json"), Path.join(prodPath, "package.json"));
const cmd = mkCmd(
`babel -q ${modulePath} --no-babelrc --ignore dist -D`,
`--plugins transform-node-env-inline,minify-dead-code-elimination`,
`-d ${prodPath}`
);
return exec(cmd).then(() => {
const dist = Path.join(modulePath, "dist");
if (Fs.existsSync(dist)) {
shell.cp("-rf", dist, prodPath);
}
});
};

Expand Down

0 comments on commit 6a85b4b

Please sign in to comment.