Comments (2)
I ran into something similar you mention recently. However, the swa deploy
command is supposed to work against the output from the swa build
command.
The trick with purely static site is to make use of script commands in a package.json
to copy your source to a directory that you can pass into the swa deploy
command.
You'll need the following files (tweak commands/paths as necessary)
package.json
{
"scripts": {
"build": "robocopy src src\\dist /XD *dist* /s /purge > nul & if ErrorLevel 8 (exit /B 1) else (exit /B 0)"
}
}
The above command will copy all source files from the src
directory to src\dist
, including sub directories but excluding the dist
folder. It will also remove files in the dist
that do not exist in the source. The additional command translates the non zero success exit code from robocopy
to a zero exit code, otherwise it will fail.
swa-cli.config.json
{
"$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
"configurations": {
"app": {
"appLocation": "src",
"outputLocation": "dist",
"appBuildCommand" : "npm run build"
}
}
}
Your project directory structure should look like this:
\
¬\src
¬\src\index.html
¬\src\staticwebapp.config.json
¬\src\any-other-files-or-directories
¬\src\dist
package.json
swa-cli.config.json
Then simply run the following command from your root directory (the one above \src):
swa build && swa deploy [options]
from static-web-apps-cli.
I'm just hoping a better DX for the SWA newbies especially for the pure front-end devs. They might not know anything about Node.js or any backend stuff.
from static-web-apps-cli.
Related Issues (20)
- Wildcard routes aren't supported properly in config HOT 2
- Outdated dependencies with moderate severity security issues (CVE-2023-45857) HOT 1
- Unable to deploy SWA from Ubuntu ( `ubuntu-latest` on Azure Pipelines Hosted Agent)
- Deploying Blazor WASM to Azure Static Web App from Visual Studio
- Azure Static Web Apps Cli command failing on Linux
- Flaky CLI deployment HOT 3
- swa-cli.config.json "run" field <undefined>when "npm run vite:dev". Vite never runs
- SWA CLI and Visual Studio debugger does not connect in Visual Studio 17.8.6 HOT 2
- Dependency on json.schemastore.org breaks CLI HOT 21
- Pipelines fail due to https://json.schemastore.org/staticwebapp.config.json network timeout HOT 2
- Failed to load staticwebapp.config.json schema. Continuing without validation! HOT 3
- Old Data API builder version used HOT 3
- Custom SWA roles don't work in Data API builder HOT 1
- Deploy fails with no feedback, application is not deployed, stuck in "Uploading" forever HOT 4
- `swa [login|deploy]` fails with `Cannot spawn a message bus without a machine-id` in devcontainer
- Error message unclear when trying to deploy a Function with unsupported Node version
- No errors at deployment when using runtime v4 with managed functions
- Cannot deploy if app dist folder or function project is in project root
- SWA broken as of node version `20.13.0` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from static-web-apps-cli.