Skip to content

Commit

Permalink
allow running dev mode with different babel env target (#1249)
Browse files Browse the repository at this point in the history
* init dev target

* alias dev-es6

* modify
  • Loading branch information
1846689910 authored and jchip committed May 20, 2019
1 parent 0a97603 commit 051b146
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/electrode-archetype-react-app/arch-clap.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ function setDevelopmentEnv() {
process.env.NODE_ENV = "development";
}

function setDevelopmentTarget(args) {
if (archetype.babel.target === "default") {
const idx = args.findIndex(arg => arg.startsWith("--target"));
if (idx >= 0) {
const [arg] = args.splice(idx, 1);
process.env.ENV_TARGET = arg.substr("--target=".length);
}
}
}

function setWebpackHot() {
process.env.HMR = "true";
}
Expand Down Expand Up @@ -350,6 +360,10 @@ function makeTasks(xclap) {
.filter(name => name !== "default")
.map(name => `dist-${name}`);

const setEnvTarget = target => {
process.env.ENV_TARGET = target;
};

let tasks = {
".mk-prod-dir": () =>
createGitIgnoreDir(Path.resolve(archetype.prodDir), "Electrode production dir"),
Expand Down Expand Up @@ -656,7 +670,7 @@ Individual .babelrc files were generated for you in src/client and src/server
Fs.writeFileSync(".isomorphic-loader-config.json", JSON.stringify({}));
}
const args = taskArgs(this.argv);

setDevelopmentTarget(args);
return [
".set.babel.env",
".webpack-dev",
Expand All @@ -669,6 +683,12 @@ Individual .babelrc files were generated for you in src/client and src/server
}
},

"dev-es6": {
desc:
"Start your app with watch in development mode with webpack-dev-server with ENV_TARGET=es6",
task: ["dev --target=es6"]
},

"dev-static": {
desc: "Start server in development mode with statically built files",
task: ["build-dev-static", "app-server"]
Expand Down

0 comments on commit 051b146

Please sign in to comment.