-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Off-line support with auto generated service worker #853
Comments
Can you have a try with |
What you can do while the <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script src="/sw.js"></script> <!-- Import the placeholder file -->
</body>
</html> And the call the workbox-cli after "scripts": {
"build": "vite build && workbox generateSW"
} For this to work though you need to have the workbox-cli installed and a module.exports = {
globDirectory: 'dist/',
globPatterns: ['**/*.{js,css,ico,html}'], // add all .js,.css,.ico and .html files to the service workers manifest
swDest: 'dist/sw.js', // This is the important part It is awkward yes, but currently the only working solution that I could find. |
End the end we just made a local copy for the use case and hard installed it. |
Did tried your config, my html having ended like this.
The <script src="/sw.js"></script> did not included to the dist html. Please help |
This is out of scope for Vite. |
Is your feature request related to a problem? Please describe.
One of my apps needs off-line support
Describe the solution you'd like
Auto generated service worker based on the assets
The text was updated successfully, but these errors were encountered: