Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #38 from AngelMunoz/static-files-updates
Browse files Browse the repository at this point in the history
Static files updates
  • Loading branch information
AngelMunoz authored Oct 6, 2021
2 parents 3ad5b20 + 5ea7368 commit 8af0cf4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 27 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@
"stopAtEntry": false,
"console": "integratedTerminal"
},
{
"name": "NET6 react-tsx",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/Perla/bin/Debug/net6.0/Perla.dll",
"args": [
"build"
],
"cwd": "${workspaceFolder}/src/react-tsx",
"stopAtEntry": false,
"console": "integratedTerminal"
},
{
"name": "NET5 build",
"type": "coreclr",
Expand Down
60 changes: 33 additions & 27 deletions src/Perla/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ module Build =
let indexFile = defaultArg config.index "index.html"

let outDir =
match config.build with
| Some config -> config.outDir |> Option.defaultValue "./dist"
| None -> "./dist"
config.build
|> Option.map (fun build -> build.outDir)
|> Option.flatten
|> Option.defaultValue "./dist"

let content =
File.ReadAllText(Path.GetFullPath(indexFile))
Expand Down Expand Up @@ -213,33 +214,38 @@ module Build =
opts.RecurseSubdirectories <- true

let getDirectories (map: Map<string, string>) =
seq {
for key in map.Keys do
yield!
Directory.EnumerateFiles(Path.GetFullPath(key), "*.*", opts)
|> Seq.filter
(fun file ->
not <| file.Contains(".fable")
&& not <| file.Contains("bin")
&& not <| file.Contains("obj")
&& not <| file.Contains(".fsproj")
&& not <| file.Contains(".fs")
&& not <| file.Contains(".js")
&& not <| file.Contains(".css")
&& not <| file.Contains(".ts")
&& not <| file.Contains(".jsx")
&& not <| file.Contains(".tsx")
&& not <| file.Contains("index.html"))
}

let copyMountedFiles (dirs: string seq) =
dirs
|> Seq.iter
(fun path -> File.Copy(path, $"{outDir}/{Path.GetFileName(path)}"))
let root = Environment.CurrentDirectory

for key in map.Keys do
Directory.EnumerateFiles(Path.GetFullPath(key), "*.*", opts)
|> Seq.filter
(fun file ->
not <| file.Contains(".fable")
&& not <| file.Contains("bin")
&& not <| file.Contains("obj")
&& not <| file.Contains(".fsproj")
&& not <| file.Contains(".fs")
&& not <| file.Contains(".js")
&& not <| file.Contains(".css")
&& not <| file.Contains(".ts")
&& not <| file.Contains(".jsx")
&& not <| file.Contains(".tsx")
&& not <| file.Contains("index.html"))
|> Seq.iter
(fun path ->
let posPath = path.Replace(root, $"{outDir}")

try
Path.GetDirectoryName posPath
|> Directory.CreateDirectory
|> ignore
with
| _ -> ()

File.Copy(path, posPath))

devServer.mountDirectories
|> Option.map getDirectories
|> Option.map copyMountedFiles
|> ignore

let cssFiles =
Expand Down

0 comments on commit 8af0cf4

Please sign in to comment.