vite-plugin-rpx 0.11.0

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2024 Open Web Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ <p align="center"><img src="https://github.com/stacksjs/rpx/blob/main/.github/art/cover.jpg?raw=true" alt="Social Card of this repo"></p>
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![GitHub Actions][github-actions-src]][github-actions-href]
5
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
6
+ <!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
7
+ <!-- [![Codecov][codecov-src]][codecov-href] -->
8
+
9
+ # Simplified Vite Plugin for Pretty URLs and HTTPS
10
+
11
+ This plugin provides a simplified approach to adding pretty URLs and HTTPS support to your Vite applications without the complexity of a full reverse proxy setup.
12
+
13
+ ## Features
14
+
15
+ - **Pretty URLs**: Automatically serve `/about` as `/about.html` or `/about/index.html`
16
+ - **HTTPS Support**: Generate and use self-signed certificates
17
+ - **Custom Domain**: Add entries to `/etc/hosts` for local domains
18
+ - **No WebSocket Issues**: Works without the WebSocket port allocation loops that can happen with reverse proxies
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install vite-plugin-pretty-urls-https
24
+ # or
25
+ yarn add vite-plugin-pretty-urls-https
26
+ # or
27
+ bun add vite-plugin-pretty-urls-https
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### In your vite.config.js:
33
+
34
+ ```js
35
+ import { defineConfig } from 'vite'
36
+ import { SimplifiedVitePlugin } from 'vite-plugin-pretty-urls-https'
37
+
38
+ export default defineConfig({
39
+ plugins: [
40
+ SimplifiedVitePlugin({
41
+ // Enable/disable the plugin (default: true)
42
+ enabled: true,
43
+
44
+ // Custom domain (default: 'localhost')
45
+ domain: 'myapp.localhost',
46
+
47
+ // Enable HTTPS (default: false)
48
+ https: true,
49
+
50
+ // Enable clean URLs (default: false)
51
+ cleanUrls: true,
52
+
53
+ // Base SSL certificate directory (default: '~/.stacksjs/ssl')
54
+ sslDir: '~/.stacksjs/ssl',
55
+
56
+ // Enable verbose logging (default: false)
57
+ verbose: true
58
+ })
59
+ ]
60
+ })
61
+ ```
62
+
63
+ ## Migrating from rpx
64
+
65
+ If you're currently using rpx and facing WebSocket port allocation issues, here's how to migrate to this simplified plugin:
66
+
67
+ ### 1. Before (rpx)
68
+
69
+ ```js
70
+ import { VitePluginRpx } from '@stacksjs/vite-plugin-rpx'
71
+ import { defineConfig } from 'vite'
72
+
73
+ export default defineConfig({
74
+ plugins: [
75
+ VitePluginRpx({
76
+ domain: 'myapp.localhost',
77
+ https: true,
78
+ cleanUrls: true
79
+ })
80
+ ]
81
+ })
82
+ ```
83
+
84
+ ### 2. After (simplified plugin)
85
+
86
+ ```js
87
+ import { defineConfig } from 'vite'
88
+ import { SimplifiedVitePlugin } from 'vite-plugin-pretty-urls-https'
89
+
90
+ export default defineConfig({
91
+ plugins: [
92
+ SimplifiedVitePlugin({
93
+ domain: 'myapp.localhost',
94
+ https: true,
95
+ cleanUrls: true
96
+ })
97
+ ]
98
+ })
99
+ ```
100
+
101
+ Key differences:
102
+ - No WebSocket port allocation issues
103
+ - No separate proxy server running
104
+ - More streamlined approach
105
+ - Still retains pretty URLs and HTTPS functionality
106
+
107
+ ## Difference from the complex proxy version
108
+
109
+ This plugin directly modifies Vite's server configuration rather than creating a separate proxy server:
110
+
111
+ 1. **HTTPS**: Adds HTTPS directly to Vite's dev server
112
+ 2. **Pretty URLs**: Uses middleware to rewrite URLs on the fly
113
+ 3. **No WebSocket Issues**: Avoids the WebSocket port allocation problems that occur with proxies
114
+
115
+ ## How it works
116
+
117
+ Unlike the full rpx package which creates a reverse proxy, this plugin:
118
+
119
+ 1. **Pretty URLs**: Uses Vite middleware to try different URL patterns when a file isn't found
120
+ 2. **HTTPS**: Configures Vite's built-in HTTPS server with certificates
121
+ 3. **Custom Domain**: Adds entries to your hosts file (with permission)
122
+
123
+ This approach is much simpler and avoids the complex port allocation logic that can lead to WebSocket issues.
124
+
125
+ ## Troubleshooting
126
+
127
+ ### Certificate Issues
128
+
129
+ If your browser doesn't trust the certificates:
130
+
131
+ 1. Navigate to `https://yourapp.localhost`
132
+ 2. Accept the security warning
133
+ 3. The certificate should be stored in your system keychain
134
+
135
+ If you need to regenerate certificates, delete the files from the SSL directory (default: `~/.stacksjs/ssl`).
136
+
137
+ ### Hosts File
138
+
139
+ The plugin attempts to add entries to your `/etc/hosts` file but may require sudo. If you see permission errors, manually add:
140
+
141
+ ```
142
+ 127.0.0.1 yourapp.localhost
143
+ ::1 yourapp.localhost
144
+ ```
145
+
146
+ ## License
147
+
148
+ MIT
@@ -0,0 +1,11 @@
1
+ import { SimplifiedVitePlugin } from './simplified-plugin';
2
+ import type { Plugin } from 'vite';
3
+ import type { VitePluginRpxOptions } from './types';
4
+ export type { SimplifiedPluginOptions } from './simplified-plugin';
5
+ /**
6
+ * Legacy VitePluginRpx implementation - kept for backward compatibility
7
+ * @deprecated Use SimplifiedVitePlugin instead to avoid WebSocket port allocation issues
8
+ */
9
+ export declare function VitePluginRpx(options: VitePluginRpxOptions): Plugin;
10
+ export { SimplifiedVitePlugin } from './simplified-plugin';
11
+ export default SimplifiedVitePlugin;