From a0600fb49e89ebe093324da80df3a94a181069de Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 10 Nov 2022 18:53:17 -0300 Subject: [PATCH] deploy: minify JS assets on production --- .env.sample | 1 + Rakefile.rb | 15 ++++++++++++--- webpack.config.js | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.env.sample b/.env.sample index f29b5f7..b822815 100644 --- a/.env.sample +++ b/.env.sample @@ -1,3 +1,4 @@ DEPLOY_HOSTNAME= DEPLOY_USERNAME= DEPLOY_PATH= +NODE_ENV= diff --git a/Rakefile.rb b/Rakefile.rb index dc7838d..ac1a0b9 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -24,14 +24,23 @@ task server: ["nanoc:compile"] do end namespace :deploy do - task local: ["nanoc:compile"] do + task local: ["env:development", "nanoc:compile"] do Deploy::Local.call end - task remote: ["nanoc:clean", "nanoc:compile"] do + task remote: ["env:production", "nanoc:clean", "nanoc:compile"] do + Deploy::Remote.call + end +end + +namespace :env do + task :production do require "dotenv" Dotenv.load - Deploy::Remote.call + end + + task :development do + ENV["NODE_ENV"] ||= "development" end end diff --git a/webpack.config.js b/webpack.config.js index 35885d5..7631d07 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,8 @@ const path = require('path'); +const process = require('process'); module.exports = { - mode: "development", + mode: process.env.NODE_ENV || "development", experiments: { asyncWebAssembly: true },