@despia/local 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -74
- package/package.json +2 -6
- package/src/next.js +0 -69
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Universal build plugin to generate `despia/local.json` manifest for [Despia](htt
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- **Universal Support** - Works with Vite, Webpack, Rollup,
|
|
11
|
+
- **Universal Support** - Works with Vite, Webpack, Rollup, Nuxt, SvelteKit, Astro, Remix, esbuild, Parcel, and more
|
|
12
12
|
- **Zero Dependencies** - Uses only Node.js built-in modules
|
|
13
13
|
- **Automatic Asset Discovery** - Collects all output files (JS, CSS, images, fonts, HTML, etc.)
|
|
14
14
|
- **Root-Relative Paths** - Formats all paths as root-relative (starting with `/`)
|
|
@@ -356,8 +356,8 @@ npx despia-local [outputDir] [entryHtml] [--output|-o manifestPath]
|
|
|
356
356
|
npx despia-local dist
|
|
357
357
|
|
|
358
358
|
# Custom output location (e.g., for Vercel/Netlify)
|
|
359
|
-
npx despia-local
|
|
360
|
-
npx despia-local
|
|
359
|
+
npx despia-local dist --output public/despia/local.json
|
|
360
|
+
npx despia-local build -o public/manifest.json
|
|
361
361
|
```
|
|
362
362
|
|
|
363
363
|
## Framework Support
|
|
@@ -430,46 +430,6 @@ export default {
|
|
|
430
430
|
};
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
-
### Next.js
|
|
434
|
-
|
|
435
|
-
**Recommended: Client-Side Apps for Local/Offline Apps**
|
|
436
|
-
|
|
437
|
-
For local/offline apps, we **recommend using client-side frameworks** like React + Vite or Create React App instead of Next.js. Client-side apps are better suited for offline/local deployment because:
|
|
438
|
-
|
|
439
|
-
- All features are client-side by default
|
|
440
|
-
- No server-side dependencies
|
|
441
|
-
- Simpler build and deployment
|
|
442
|
-
- Better offline support
|
|
443
|
-
|
|
444
|
-
See the [React/Vite](#react--vite) section for examples.
|
|
445
|
-
|
|
446
|
-
**Supported: Static Export Only**
|
|
447
|
-
|
|
448
|
-
If you're using Next.js, this plugin supports apps using `output: 'export'` (static export mode).
|
|
449
|
-
|
|
450
|
-
```javascript
|
|
451
|
-
// next.config.js
|
|
452
|
-
const withDespiaLocal = require('@despia/local/next');
|
|
453
|
-
|
|
454
|
-
module.exports = withDespiaLocal({
|
|
455
|
-
entryHtml: 'index.html',
|
|
456
|
-
outDir: 'out' // Next.js static export directory
|
|
457
|
-
})({
|
|
458
|
-
output: 'export',
|
|
459
|
-
// your Next.js config
|
|
460
|
-
});
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
**For SSR Apps with Separate Static Build:**
|
|
464
|
-
|
|
465
|
-
If you need SSR for your main site but want a static build for the local app, Next.js can easily generate a separate static build. You can set up a mini CI/CD pipeline to:
|
|
466
|
-
|
|
467
|
-
- Keep your main site as SSR (better for SEO, dynamic content)
|
|
468
|
-
- Generate a separate static export build for the local/offline app
|
|
469
|
-
- Deploy both builds independently
|
|
470
|
-
|
|
471
|
-
**Note**: Setting up the CI/CD pipeline for dual builds (SSR main site + static local app) requires custom configuration based on your hosting provider and build setup. You'll need to figure out the deployment strategy yourself - this plugin only handles manifest generation for the static export build.
|
|
472
|
-
|
|
473
433
|
### Nuxt
|
|
474
434
|
|
|
475
435
|
```javascript
|
|
@@ -742,37 +702,6 @@ The generated manifest is then used by Despia during app hydration and updates t
|
|
|
742
702
|
- Paths starting with `/` are preserved as-is
|
|
743
703
|
- Windows backslashes are converted to forward slashes
|
|
744
704
|
|
|
745
|
-
### Next.js Troubleshooting
|
|
746
|
-
|
|
747
|
-
**Static Export Issues:**
|
|
748
|
-
|
|
749
|
-
**Manifest not generated:**
|
|
750
|
-
1. Ensure you're using `output: 'export'` in your `next.config.js`
|
|
751
|
-
2. Verify the plugin is correctly configured with `withDespiaLocal()`
|
|
752
|
-
3. Check that `out/` directory exists after build
|
|
753
|
-
4. Ensure `entryHtml` matches your actual entry HTML file
|
|
754
|
-
|
|
755
|
-
**Wrong directory:**
|
|
756
|
-
- For static export: Use `out/` directory (Next.js default for static export)
|
|
757
|
-
- Never use `.next/` for static export (that's for SSR builds)
|
|
758
|
-
|
|
759
|
-
**Manifest not accessible:**
|
|
760
|
-
- Manifest is generated in `out/despia/local.json`
|
|
761
|
-
- Ensure your hosting provider serves files from the `out/` directory
|
|
762
|
-
- Static export output should be served as static files
|
|
763
|
-
|
|
764
|
-
**SSR Apps (Not Officially Supported):**
|
|
765
|
-
|
|
766
|
-
**Important**: This plugin does **not** officially support Next.js SSR apps. SSR requires custom tooling specific to your hosting provider.
|
|
767
|
-
|
|
768
|
-
If you choose to use post-build scripts for SSR (unsupported):
|
|
769
|
-
1. Use `.next/static/` directory (client assets only)
|
|
770
|
-
2. Never include `.next/server/` (server code, not needed)
|
|
771
|
-
3. Customize the approach based on your hosting provider's requirements
|
|
772
|
-
4. This is experimental and not guaranteed to work reliably
|
|
773
|
-
|
|
774
|
-
For production SSR apps, implement provider-specific solutions rather than relying on this plugin.
|
|
775
|
-
|
|
776
705
|
## Contributing
|
|
777
706
|
|
|
778
707
|
Contributions welcome! Please open an issue or submit a pull request.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@despia/local",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Universal build plugin to generate despia/local.json manifest for offline caching in Despia web-native apps. Supports Vite, Webpack, Rollup,
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Universal build plugin to generate despia/local.json manifest for offline caching in Despia web-native apps. Supports Vite, Webpack, Rollup, Nuxt, SvelteKit, Astro, Remix, esbuild, Parcel, and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/core.js",
|
|
7
7
|
"bin": {
|
|
@@ -20,9 +20,6 @@
|
|
|
20
20
|
"./rollup": {
|
|
21
21
|
"import": "./src/rollup.js"
|
|
22
22
|
},
|
|
23
|
-
"./next": {
|
|
24
|
-
"import": "./src/next.js"
|
|
25
|
-
},
|
|
26
23
|
"./nuxt": {
|
|
27
24
|
"import": "./src/nuxt.js"
|
|
28
25
|
},
|
|
@@ -67,7 +64,6 @@
|
|
|
67
64
|
"vite",
|
|
68
65
|
"webpack",
|
|
69
66
|
"rollup",
|
|
70
|
-
"nextjs",
|
|
71
67
|
"nuxt",
|
|
72
68
|
"sveltekit",
|
|
73
69
|
"astro",
|
package/src/next.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Next.js integration for generating despia/local.json manifest
|
|
3
|
-
*
|
|
4
|
-
* Usage for static export:
|
|
5
|
-
* const withDespiaLocal = require('@despia/local/next');
|
|
6
|
-
* module.exports = withDespiaLocal({
|
|
7
|
-
* entryHtml: 'index.html',
|
|
8
|
-
* outDir: 'out' // Next.js static export directory
|
|
9
|
-
* })({
|
|
10
|
-
* output: 'export',
|
|
11
|
-
* // your Next.js config
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* For SSR apps, use the post-build script approach:
|
|
15
|
-
* // package.json
|
|
16
|
-
* {
|
|
17
|
-
* "scripts": {
|
|
18
|
-
* "build": "next build",
|
|
19
|
-
* "postbuild": "despia-local .next/static --output public/despia/local.json"
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* Or use the webpack plugin approach:
|
|
24
|
-
* const DespiaLocalPlugin = require('@despia/local/webpack');
|
|
25
|
-
* module.exports = {
|
|
26
|
-
* webpack: (config) => {
|
|
27
|
-
* config.plugins.push(new DespiaLocalPlugin({ outDir: '.next' }));
|
|
28
|
-
* return config;
|
|
29
|
-
* }
|
|
30
|
-
* };
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
import { generateManifest } from './core.js';
|
|
34
|
-
import DespiaLocalPlugin from './webpack.js';
|
|
35
|
-
|
|
36
|
-
export function withDespiaLocal(pluginOptions = {}) {
|
|
37
|
-
const localConfig = {
|
|
38
|
-
outDir: pluginOptions.outDir || '.next',
|
|
39
|
-
entryHtml: pluginOptions.entryHtml || 'index.html',
|
|
40
|
-
...pluginOptions
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (nextConfig = {}) => {
|
|
44
|
-
const existingWebpack = nextConfig.webpack;
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
...nextConfig,
|
|
48
|
-
webpack: (config, options) => {
|
|
49
|
-
// Add Despia Local plugin
|
|
50
|
-
config.plugins.push(
|
|
51
|
-
new DespiaLocalPlugin({
|
|
52
|
-
outDir: localConfig.outDir,
|
|
53
|
-
entryHtml: localConfig.entryHtml
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// Call existing webpack config if present
|
|
58
|
-
if (typeof existingWebpack === 'function') {
|
|
59
|
-
return existingWebpack(config, options);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return config;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Also export as CommonJS for Next.js compatibility
|
|
69
|
-
export default withDespiaLocal;
|