diff --git a/re-natal.coffee b/re-natal.coffee index 470350f..baf44cd 100644 --- a/re-natal.coffee +++ b/re-natal.coffee @@ -24,6 +24,8 @@ projNameRx = /\$PROJECT_NAME\$/g projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g projNameUsRx = /\$PROJECT_NAME_UNDERSCORED\$/g interfaceDepsRx = /\$INTERFACE_DEPS\$/g +devProfilesRx = /\$DEV_PROFILES\$/g +prodProfilesRx = /\$PROD_PROFILES\$/g platformRx = /\$PLATFORM\$/g devHostRx = /\$DEV_HOST\$/g ipAddressRx = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/i @@ -364,9 +366,18 @@ copySrcFiles = (interfaceName, projName, projNameUs, projNameHyph) -> shimCljsNamespace(namespace) copyProjectClj = (interfaceName, projNameHyph) -> + devProfileTemplate = readFile "#{resources}/dev.profile" + prodProfileTemplate = readFile "#{resources}/prod.profile" + + devProfiles = [] + prodProfiles = [] + for platform in platforms + devProfiles.push devProfileTemplate.replace(platformRx, platform) + prodProfiles.push prodProfileTemplate.replace(platformRx, platform) + fs.copySync("#{resources}/project.clj", "project.clj") deps = interfaceConf[interfaceName].deps.join("\n") - edit 'project.clj', [[projNameHyphRx, projNameHyph], [interfaceDepsRx, deps]] + edit 'project.clj', [[projNameHyphRx, projNameHyph], [interfaceDepsRx, deps], [devProfilesRx, devProfiles.join("\n")], [prodProfilesRx, prodProfiles.join("\n")]] init = (interfaceName, projName) -> if projName.toLowerCase() is 'react' or !projName.match validNameRx @@ -394,7 +405,7 @@ init = (interfaceName, projName) -> fs.unlinkSync corePath copyProjectClj(interfaceName, projNameHyph) - + copySrcFiles(interfaceName, projName, projNameUs, projNameHyph) copyDevEnvironmentFiles(interfaceName, projNameHyph, projName, defaultEnvRoots.dev, "localhost") diff --git a/resources/dev.profile b/resources/dev.profile new file mode 100644 index 0000000..ef9856e --- /dev/null +++ b/resources/dev.profile @@ -0,0 +1,7 @@ + {:id "$PLATFORM$" + :source-paths ["src" "env/dev"] + :figwheel true + :compiler {:output-to "target/$PLATFORM$/not-used.js" + :main "env.$PLATFORM$.main" + :output-dir "target/$PLATFORM$" + :optimizations :none}} \ No newline at end of file diff --git a/resources/prod.profile b/resources/prod.profile new file mode 100644 index 0000000..3d73078 --- /dev/null +++ b/resources/prod.profile @@ -0,0 +1,9 @@ + {:id "$PLATFORM$" + :source-paths ["src" "env/prod"] + :compiler {:output-to "index.$PLATFORM$.js" + :main "env.$PLATFORM$.main" + :output-dir "target/$PLATFORM$" + :static-fns true + :optimize-constants true + :optimizations :simple + :closure-defines {"goog.DEBUG" false}}} \ No newline at end of file diff --git a/resources/project.clj b/resources/project.clj index e9ba3cf..6db4b92 100644 --- a/resources/project.clj +++ b/resources/project.clj @@ -15,36 +15,10 @@ :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.8"] [com.cemerick/piggieback "0.2.1"]] :source-paths ["src" "env/dev"] - :cljsbuild {:builds [{:id "ios" - :source-paths ["src" "env/dev"] - :figwheel true - :compiler {:output-to "target/ios/not-used.js" - :main "env.ios.main" - :output-dir "target/ios" - :optimizations :none}} - {:id "android" - :source-paths ["src" "env/dev"] - :figwheel true - :compiler {:output-to "target/android/not-used.js" - :main "env.android.main" - :output-dir "target/android" - :optimizations :none}}]} + :cljsbuild {:builds [ +$DEV_PROFILES$]} :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}} - :prod {:cljsbuild {:builds [{:id "ios" - :source-paths ["src" "env/prod"] - :compiler {:output-to "index.ios.js" - :main "env.ios.main" - :output-dir "target/ios" - :static-fns true - :optimize-constants true - :optimizations :simple - :closure-defines {"goog.DEBUG" false}}} - {:id "android" - :source-paths ["src" "env/prod"] - :compiler {:output-to "index.android.js" - :main "env.android.main" - :output-dir "target/android" - :static-fns true - :optimize-constants true - :optimizations :simple - :closure-defines {"goog.DEBUG" false}}}]}}}) + :prod {:cljsbuild {:builds [ +$PROD_PROFILES$]}}}) + +