honox 0.1.46 → 0.1.47

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 CHANGED
@@ -774,7 +774,10 @@ export default defineConfig({
774
774
  plugins: [
775
775
  honox({
776
776
  client: {
777
- input: ['/app/style.css'],
777
+ input: [
778
+ '/app/client.ts', // the default value -> must be added if input is overridden
779
+ '/app/style.css', // add the style file entrypoint
780
+ ],
778
781
  },
779
782
  }),
780
783
  build(),
@@ -848,12 +851,10 @@ If you want to use Cloudflare's Bindings in your development environment, create
848
851
  "name": "my-project-name",
849
852
  "main": "./dist/index.js",
850
853
  "compatibility_date": "2025-08-03",
851
- "compatibility_flags": [
852
- "nodejs_compat"
853
- ],
854
+ "compatibility_flags": ["nodejs_compat"],
854
855
  "assets": {
855
- "directory": "./dist"
856
- }
856
+ "directory": "./dist",
857
+ },
857
858
  }
858
859
  ```
859
860
 
@@ -947,12 +948,10 @@ Add the `wrangler.jsonc`:
947
948
  "name": "my-project-name",
948
949
  "main": "./dist/index.js",
949
950
  "compatibility_date": "2025-08-03",
950
- "compatibility_flags": [
951
- "nodejs_compat"
952
- ],
951
+ "compatibility_flags": ["nodejs_compat"],
953
952
  "assets": {
954
- "directory": "./dist"
955
- }
953
+ "directory": "./dist",
954
+ },
956
955
  }
957
956
  ```
958
957
 
@@ -970,11 +969,11 @@ export default defineConfig({
970
969
  plugins: [
971
970
  honox({
972
971
  devServer: { adapter },
973
- client: { input: ['./app/style.css'] }
972
+ client: { input: ['/app/client.ts', '/app/style.css'] },
974
973
  }),
975
974
  tailwindcss(),
976
- build()
977
- ]
975
+ build(),
976
+ ],
978
977
  })
979
978
  ```
980
979
 
@@ -1006,11 +1005,11 @@ export default defineConfig({
1006
1005
  plugins: [
1007
1006
  honox({
1008
1007
  devServer: { adapter },
1009
- client: { input: ['./app/style.css'] }
1008
+ client: { input: ['/app/client.ts', '/app/style.css'] },
1010
1009
  }),
1011
1010
  tailwindcss(),
1012
- build()
1013
- ]
1011
+ build(),
1012
+ ],
1014
1013
  })
1015
1014
  ```
1016
1015
 
@@ -1028,6 +1027,28 @@ cd ./dist && bun index.js
1028
1027
 
1029
1028
  **Note**: When running on-premises, make sure to change the working directory to the output directory (e.g., `cd ./dist`). Otherwise, JavaScript, CSS, and static assets may not be resolved correctly.
1030
1029
 
1030
+ When using environment variables in a HonoX application, you may notice that variables like `process.env.MY_VAR` work in development but not in the built application. This is because Vite optimizes `process.env` to an empty object during the build process.
1031
+
1032
+ To ensure environment variables are available at runtime, add the following to your `vite.config.ts`:
1033
+
1034
+ ```ts
1035
+ export default defineConfig({
1036
+ define: {
1037
+ 'process.env': 'process.env', // <=== Add this line
1038
+ },
1039
+ plugins: [
1040
+ honox({
1041
+ devServer: { adapter },
1042
+ client: { input: ['/app/client.ts', '/app/style.css'] },
1043
+ }),
1044
+ tailwindcss(),
1045
+ build(),
1046
+ ],
1047
+ })
1048
+ ```
1049
+
1050
+ This disables Vite's optimization of `process.env`, allowing your built application to access environment variables as expected. For more details, see [issue #307](https://github.com/honojs/honox/issues/307#issuecomment-3179529432).
1051
+
1031
1052
  ## Examples
1032
1053
 
1033
1054
  - https://github.com/yusukebe/honox-examples
@@ -5,7 +5,6 @@ type ClientOptions = {
5
5
  assetsDir?: string;
6
6
  input?: string[];
7
7
  };
8
- declare const defaultOptions: ClientOptions;
9
8
  declare function client(options?: ClientOptions): Plugin;
10
9
 
11
- export { type ClientOptions, client as default, defaultOptions };
10
+ export { type ClientOptions, client as default };
@@ -1,7 +1,7 @@
1
1
  const defaultOptions = {
2
2
  jsxImportSource: "hono/jsx/dom",
3
3
  assetsDir: "static",
4
- input: []
4
+ input: ["/app/client.ts"]
5
5
  };
6
6
  function client(options) {
7
7
  return {
@@ -13,11 +13,10 @@ function client(options) {
13
13
  return false;
14
14
  },
15
15
  config: () => {
16
- const input = options?.input ?? defaultOptions.input ?? [];
17
16
  return {
18
17
  build: {
19
18
  rollupOptions: {
20
- input: ["/app/client.ts", ...input]
19
+ input: options?.input ?? defaultOptions.input
21
20
  },
22
21
  assetsDir: options?.assetsDir ?? defaultOptions.assetsDir,
23
22
  manifest: true
@@ -31,6 +30,5 @@ function client(options) {
31
30
  }
32
31
  var client_default = client;
33
32
  export {
34
- client_default as default,
35
- defaultOptions
33
+ client_default as default
36
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honox",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "scripts": {