Bird
Raised Fist0
Vueframework~20 mins

Deployment to static hosting in Vue - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Vue Static Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What happens when you deploy a Vue app without configuring the base URL for static hosting?

You deploy a Vue 3 app to a static hosting service under a subfolder (e.g., https://example.com/myapp/) but forget to set the base option in vue.config.js. What will users most likely experience?

AStatic assets like CSS and JS fail to load, causing a broken UI.
BThe app loads correctly with all routes working as expected.
CThe app redirects users to the root domain instead of the subfolder.
DThe app shows a blank page with no errors in the console.
Attempts:
2 left
💡 Hint

Think about how URLs for assets are resolved when the base path is not set.

📝 Syntax
intermediate
2:00remaining
Which vue.config.js snippet correctly sets the base URL for deploying to /app/ on static hosting?

Choose the correct syntax to configure Vue CLI to serve the app from the /app/ subfolder.

Amodule.exports = { baseUrl: '/app/' }
Bmodule.exports = { publicPath: '/app/' }
Cmodule.exports = { base: '/app/' }
Dexport default { publicPath: '/app/' }
Attempts:
2 left
💡 Hint

Check the official Vue CLI documentation for the correct option name.

🔧 Debug
advanced
2:00remaining
Why does the Vue app show 404 errors on page refresh after deployment to static hosting?

You deployed a Vue app using history mode for routing on static hosting. When you refresh a page other than the root, you get a 404 error. Why?

AVue Router is not installed properly in the project.
BThe app's <code>publicPath</code> is set incorrectly causing asset loading errors.
CStatic hosting does not support client-side routing with history mode by default.
DThe app's main <code>index.html</code> file is missing from the deployment.
Attempts:
2 left
💡 Hint

Think about how static servers handle URLs and client-side routing.

🧠 Conceptual
advanced
2:00remaining
What is the main advantage of using hash mode routing for Vue apps on static hosting?

Why might you choose hash mode routing instead of history mode when deploying a Vue app to static hosting?

AHash mode routing improves SEO by creating clean URLs.
BHash mode routing reduces the app bundle size significantly.
CHash mode routing enables server-side rendering automatically.
DHash mode routing allows the app to work without server-side configuration for route fallback.
Attempts:
2 left
💡 Hint

Consider how static servers handle URLs with hashes versus normal paths.

❓ state_output
expert
2:00remaining
What is the final URL in the browser after deploying a Vue app with publicPath: '/site/' and navigating to /site/dashboard using history mode?

You deployed a Vue app with publicPath set to /site/. The app uses Vue Router in history mode. You navigate inside the app to the dashboard page. What URL will the browser show?

Ahttps://example.com/site/dashboard
Bhttps://example.com/site/#/dashboard
Chttps://example.com/dashboard
Dhttps://example.com/#/dashboard
Attempts:
2 left
💡 Hint

Remember how history mode routing works with base URLs.

Practice

(1/5)
1. What is the main purpose of running npm run build in a Vue project before deployment?
easy
A. To start the development server for testing
B. To create optimized static files ready for hosting
C. To install project dependencies
D. To generate backend API endpoints

Solution

  1. Step 1: Understand the build command role

    npm run build compiles Vue files into static assets like HTML, CSS, and JS.
  2. Step 2: Identify deployment needs

    Static hosting requires these optimized files to serve the app efficiently.
  3. Final Answer:

    To create optimized static files ready for hosting -> Option B
  4. Quick Check:

    Build creates static files = A [OK]
Hint: Build command prepares files for static hosting [OK]
Common Mistakes:
  • Confusing build with starting dev server
  • Thinking build installs dependencies
  • Expecting backend code generation
2. Which folder should you upload to your static hosting service after building a Vue app?
easy
A. dist
B. src
C. node_modules
D. public

Solution

  1. Step 1: Identify build output folder

    Vue's build process outputs static files into the dist folder.
  2. Step 2: Understand hosting requirements

    Static hosts serve files from the dist folder contents, not source or dependencies.
  3. Final Answer:

    dist -> Option A
  4. Quick Check:

    Upload dist folder = B [OK]
Hint: Upload the dist folder contents for deployment [OK]
Common Mistakes:
  • Uploading source code instead of built files
  • Uploading node_modules which is unnecessary
  • Uploading public folder only
3. After deploying a Vue app's dist folder to GitHub Pages, what will happen if you visit the site URL?
medium
A. You will see the raw source code files
B. You will get a server error because GitHub Pages doesn't support Vue
C. You will see the Vue app running as expected
D. You will be redirected to the Vue CLI homepage

Solution

  1. Step 1: Understand GitHub Pages hosting

    GitHub Pages serves static files, perfect for Vue apps built into static assets.
  2. Step 2: Predict site behavior

    Visiting the URL loads the static files, so the Vue app runs normally in the browser.
  3. Final Answer:

    You will see the Vue app running as expected -> Option C
  4. Quick Check:

    Static hosting runs Vue app = A [OK]
Hint: Static hosting runs built Vue app directly [OK]
Common Mistakes:
  • Thinking GitHub Pages can't host Vue apps
  • Expecting server errors on static hosts
  • Confusing source code with built app
4. You deployed your Vue app to Firebase Hosting but the app shows a blank page. What is the most likely cause?
medium
A. You did not configure Firebase to serve the dist folder
B. You uploaded the src folder instead of dist
C. You used the wrong Firebase project ID
D. You forgot to run npm run build before deploying

Solution

  1. Step 1: Check build and upload correctness

    Assuming build and upload are correct, the blank page often means Firebase isn't serving the right folder.
  2. Step 2: Verify Firebase hosting config

    Firebase needs firebase.json to point to dist as the public directory to serve files.
  3. Final Answer:

    You did not configure Firebase to serve the dist folder -> Option A
  4. Quick Check:

    Firebase config public folder = D [OK]
Hint: Check Firebase public folder setting matches dist [OK]
Common Mistakes:
  • Uploading wrong folder but blaming build
  • Ignoring firebase.json public directory setting
  • Assuming project ID causes blank page
5. You want to deploy a Vue app with client-side routing to Netlify. Which step is essential to ensure routing works correctly on page reload?
hard
A. Rename dist folder to public
B. Disable JavaScript in the browser
C. Use server-side rendering instead of static hosting
D. Add a _redirects file with /index.html 200 rule

Solution

  1. Step 1: Understand client-side routing issue

    On reload, Netlify tries to find the route as a file and fails without redirect.
  2. Step 2: Use Netlify redirect rule

    Adding a _redirects file with /index.html 200 tells Netlify to serve index.html for all routes.
  3. Final Answer:

    Add a _redirects file with /index.html 200 rule -> Option D
  4. Quick Check:

    Redirect rule fixes routing reload = C [OK]
Hint: Use _redirects file for client-side routing on Netlify [OK]
Common Mistakes:
  • Ignoring redirect rules causing 404 on reload
  • Thinking JavaScript disabling helps routing
  • Confusing folder names for deployment
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard