Azure / Azure/static-web-apps

Unable to build vue 3 project in github actions

Open
#1,372 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

Unable to deploy vue 3 webapp (using vite) to Azure. I've created the static webapp in the Azure portal and configured github actions to deploy the code, but I'm getting the following error when building the project:
![image](https://github.com/Azure/static-web-apps/assets/60574797/710628af-c57d-4b1b-911e-610c130913f0)

Build works fine locally, it only fails in github actions. One weird thing I noticed is a mismatch in numbers reported by vite. You can see in the screenshot above I get 261 modules transformed, but when I run the build command locally I get 741 modules transformed.

Here is the content of the layouts.ts file
```
import MainLayout from "@/views/layout/MainLayout.vue";
import DashboardLayout from "@/views/layout/DashboardLayout.vue";
export default { MainLayout, DashboardLayout };
```

and here is what I have in vite.config.js
```
import { defineConfig } from "vite";
import fs from "fs";
import vue from "@vitejs/plugin-vue";
import dns from "dns";
import UnoCSS from "unocss/vite";
import path from "path";

dns.setDefaultResultOrder("verbatim");

export default defineConfig({
plugins: [vue(), UnoCSS()],
server: {
port: 3000,
host: "localhost",
https: {
key: fs.readFileSync("./localhost-key.pem"),
cert: fs.readFileSync("./localhost.pem"),
},
},
css: {
preprocessorOptions: {
scss: { additionalData: `@import "/src/styles/variables.scss";` },
},
},
resolve: {
alias: {
"@/": path.join(__dirname, "src/"),
},
},
hmr: {
host: "localhost",
protocol: "ws",
},
});
```

here is my tsconfig.json file
```
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"gapi",
"gapi.auth2",
"facebook-js-sdk",
"vite/client"
],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": ["node_modules"]
}
```

finally, this is the contents of the azure-static-web-apps workflow created by the Azure portal:
```
name: Azure Static Web Apps CI/CD

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AGREEABLE_MEADOW_01D1BA610 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "dist" # Built app content directory - optional
skip_api_build: true
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AGREEABLE_MEADOW_01D1BA610 }}
action: "close"
```

this is the structure of my project:
![image](https://github.com/Azure/static-web-apps/assets/60574797/ee6bd04e-480c-44d8-9b93-15b8d6572ca1)

Do you have any idea what could be going on? I tried to play around with the aliases but no luck

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.