Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set babel env target for dev mode with archetype v5 #1249

Merged
merged 3 commits into from
May 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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