mirror of
https://github.com/typeable/octopod.git
synced 2024-10-05 19:27:24 +03:00
Reduced size of frontend js (#60)
* Reduced size of frontend js * Pass externs to jscc * Cleaned things up
This commit is contained in:
parent
a610411aec
commit
61d53d3600
@ -38,10 +38,13 @@ let
|
||||
in
|
||||
hsPkgs // {
|
||||
octopod-frontend-pretty =
|
||||
let frontend = hsPkgs.projectCross.ghcjs.hsPkgs.octopod-frontend.components.exes.frontend;
|
||||
in
|
||||
pkgs.runCommand "octopod-frontend-pretty"
|
||||
{ } ''
|
||||
mkdir $out
|
||||
cp ${./octopod-frontend/index.html} $out/index.html
|
||||
cp ${hsPkgs.projectCross.ghcjs.hsPkgs.octopod-frontend.components.exes.frontend}/bin/frontend.jsexe/all.js $out/all.js
|
||||
cp ${frontend}/bin/frontend.jsexe/all.js $out/all.js
|
||||
cp ${frontend}/bin/frontend.jsexe/all.js.externs $out/all.js.externs
|
||||
'';
|
||||
}
|
||||
|
@ -11,15 +11,18 @@ let
|
||||
octo-cli = hsPkgs.octo-cli.components.exes.octo;
|
||||
octopod-backend = hsPkgs.octopod-backend.components.exes.octopod-exe;
|
||||
|
||||
terser = (import sources.nixpkgs { inherit system; }).nodePackages.terser;
|
||||
closurecompiler = (import sources.nixpkgs { inherit system; }).closurecompiler;
|
||||
|
||||
octopod-frontend-ugly = pkgs.runCommand "octopod-frontend-ugly"
|
||||
{ } ''
|
||||
mkdir $out
|
||||
cp ${hsPkgs.octopod-frontend-pretty}/index.html $out/index.html
|
||||
octopod-frontend-ugly =
|
||||
let frontend = hsPkgs.octopod-frontend-pretty;
|
||||
in
|
||||
pkgs.runCommand "octopod-frontend-ugly"
|
||||
{ } ''
|
||||
mkdir $out
|
||||
cp ${../octopod-frontend/index.html} $out/index.html
|
||||
|
||||
${terser}/bin/terser ${hsPkgs.octopod-frontend-pretty}/all.js -o $out/all.js -mangle -c
|
||||
'';
|
||||
${closurecompiler}/bin/closure-compiler --compilation_level ADVANCED --jscomp_off=checkVars --warning_level QUIET --js ${frontend}/all.js --externs ${frontend}/all.js.externs --js_output_file $out/all.js
|
||||
'';
|
||||
|
||||
octopod-server-container = pkgs.dockerTools.buildImage {
|
||||
name = "octopod-server-container-slim";
|
||||
|
@ -5,10 +5,10 @@
|
||||
"homepage": "https://input-output-hk.github.io/haskell.nix",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "haskell.nix",
|
||||
"rev": "920ac43ee13d95f56d7539bece1f5ee41b10c8a9",
|
||||
"sha256": "0px60yvag24ayj9zl82cbnpixm41slj2wqw4p2vgbwnbz125hgsx",
|
||||
"rev": "9d940715665e28af6a60c760946330c6c63f2e29",
|
||||
"sha256": "0pcmab8lqxla97cd0726s1nasrwapz95wd78ps9xlv3spz5j2x0n",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/920ac43ee13d95f56d7539bece1f5ee41b10c8a9.tar.gz",
|
||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/9d940715665e28af6a60c760946330c6c63f2e29.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"niv": {
|
||||
@ -17,10 +17,10 @@
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "ba57d5a29b4e0f2085917010380ef3ddc3cf380f",
|
||||
"sha256": "1kpsvc53x821cmjg1khvp1nz7906gczq8mp83664cr15h94sh8i4",
|
||||
"rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070",
|
||||
"sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/ba57d5a29b4e0f2085917010380ef3ddc3cf380f.tar.gz",
|
||||
"url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nix-filter": {
|
||||
@ -41,10 +41,10 @@
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "eb93bf6eed08d06bc4eb08b534e544b1f9b4e966",
|
||||
"sha256": "0sm6n0m396szc5wzrkmyqff26qlf3vi9naykyj5vb0lzm485r99n",
|
||||
"rev": "5c717aad36eda145bd208f65eced1f103f60535f",
|
||||
"sha256": "14adjx3vzjpkzvlw6a0q04csip2s6cjfyxmrq63a31nm1xikfjqq",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/eb93bf6eed08d06bc4eb08b534e544b1f9b4e966.tar.gz",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/5c717aad36eda145bd208f65eced1f103f60535f.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,10 @@ let
|
||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||
in
|
||||
if ersatz == "" then drv else ersatz;
|
||||
if ersatz == "" then drv else
|
||||
# this turns the string into an actual Nix path (for both absolute and
|
||||
# relative paths)
|
||||
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
|
@ -34,6 +34,7 @@ library
|
||||
, ScopedTypeVariables
|
||||
, TypeApplications
|
||||
, TypeOperators
|
||||
, ViewPatterns
|
||||
build-depends: base
|
||||
, aeson
|
||||
, bytestring
|
||||
@ -41,7 +42,6 @@ library
|
||||
, generic-lens
|
||||
, http-api-data
|
||||
, lens
|
||||
, regex-tdfa
|
||||
, text
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
|
@ -8,13 +8,13 @@ module Common.Validation
|
||||
)
|
||||
where
|
||||
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Text.Encoding as T (encodeUtf8)
|
||||
import Text.Regex.TDFA
|
||||
|
||||
import Common.Types
|
||||
import Data.Char
|
||||
import qualified Data.Text as T
|
||||
|
||||
-- | Validates a deployment name.
|
||||
isNameValid :: DeploymentName -> Bool
|
||||
isNameValid (DeploymentName n) =
|
||||
T.encodeUtf8 n =~ ("^[a-z][a-z0-9\\-]{1,16}$" :: ByteString)
|
||||
isNameValid (DeploymentName (T.uncons -> Just (n, nn))) =
|
||||
let l = T.length nn
|
||||
in l > 0 && l < 16 && isAsciiLower n && T.all (\c -> c == '-' || isAsciiLower c || isDigit c) nn
|
||||
isNameValid _ = False
|
||||
|
@ -21,6 +21,8 @@ flag development
|
||||
description: mock host
|
||||
|
||||
executable frontend
|
||||
if impl(ghcjs >= 0.2.1)
|
||||
ghcjs-options: -dedupe
|
||||
if flag(development)
|
||||
cpp-options: -DDEVELOPMENT
|
||||
main-is: Main.hs
|
||||
|
Loading…
Reference in New Issue
Block a user