Sample for importing api module into web ui
This commit is contained in:
1 parent
71c4214cb3
commit
aa2bb376b1
5 files changed
+31
-6
No files matched your search
@@ -1,5 +1,11 @@
|
||||
|
||||
|
||||
function add(a:number, b:number) {
|
||||
return a + b + 2;
|
||||
}
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function really_long_and_unique_identifier() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
export { add , really_long_and_unique_identifier };
|
||||
@@ -0,0 +1,9 @@
|
||||
REM @echo off
|
||||
setlocal
|
||||
cd %~dp0\api
|
||||
call npm run build
|
||||
cd %~dp0\..\..\build\web\api
|
||||
call ts2fable ServiceContext.d.ts ServiceContext.fs
|
||||
cd %~dp0\ui\src
|
||||
call dotnet fable webpack
|
||||
|
||||
@@ -2,6 +2,12 @@ module Counter.State
|
||||
|
||||
open Elmish
|
||||
open Types
|
||||
open Fable.Core.Exceptions
|
||||
open Fable.Core
|
||||
|
||||
|
||||
[<Import("*",from="ServiceContext")>]
|
||||
let sc : ServiceContext.IExports = jsNative
|
||||
|
||||
let init () : Model * Cmd<Msg> =
|
||||
0, []
|
||||
@@ -9,8 +15,8 @@ let init () : Model * Cmd<Msg> =
|
||||
let update msg model =
|
||||
match msg with
|
||||
| Increment ->
|
||||
model + 1, []
|
||||
sc.add(float model, 1.) |> int, []
|
||||
| Decrement ->
|
||||
model - 1, []
|
||||
sc.add(float model, -1.) |> int, []
|
||||
| Reset ->
|
||||
0, []
|
||||
@@ -3,6 +3,8 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
||||
<Compile Include="../../../../build/web/api/*.fs" />
|
||||
<!-- Global to the app -->
|
||||
<Compile Include="Global.fs" />
|
||||
<!-- Info -->
|
||||
|
||||
@@ -20,7 +20,9 @@ var babelOptions = fableUtils.resolveBabelOptions({
|
||||
var isProduction = process.argv.indexOf("-p") >= 0;
|
||||
console.log("Bundling for " + (isProduction ? "production" : "development") + "...");
|
||||
|
||||
const output_path = resolve("../../../build/web/ui/");
|
||||
const build_path = "../../../build/";
|
||||
const output_path = resolve(build_path + "web/ui/");
|
||||
const api_path = resolve(build_path + "web/api/");
|
||||
|
||||
module.exports = {
|
||||
devtool: isProduction ? undefined : "source-map",
|
||||
@@ -31,7 +33,7 @@ module.exports = {
|
||||
},
|
||||
resolve: {
|
||||
modules: [
|
||||
"node_modules", resolve("./node_modules/")
|
||||
"node_modules", resolve("./node_modules/"), api_path
|
||||
]
|
||||
},
|
||||
devServer: {
|
||||
|
||||
Reference in new issue
Block a user