Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/config-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
.turbopack/
12 changes: 12 additions & 0 deletions examples/config-js/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Config Example</title>
</head>
<body>
<div id="root"></div>
<script src="./src/index.ts"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions examples/config-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "example-config-js",
"version": "1.0.0",
"description": "Example: utoopack with JS config (utoopack.config.mjs)",
"private": true,
"scripts": {
"build": "up build",
"dev": "up dev"
},
"devDependencies": {
"@utoo/pack": "*",
"@utoo/pack-cli": "*"
}
}
6 changes: 6 additions & 0 deletions examples/config-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare const GREETING: string;
declare const APP_VERSION: number;

// These are injected at build time via utoopack.config.mjs define
console.log("GREETING:", GREETING);
console.log("APP_VERSION:", APP_VERSION);
18 changes: 18 additions & 0 deletions examples/config-js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": [
"dom",
"ES2020"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"module": "esnext",
"moduleResolution": "node",
"noEmit": true
},
"include": [
"src"
]
}
24 changes: 24 additions & 0 deletions examples/config-js/utoopack.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-check
import { defineConfig } from "@utoo/pack";

/** Example JS config: same shape as utoopack.json, can use dynamic values. */
export default defineConfig({
define: {
GREETING: '"Hello from JS config"',
APP_VERSION: "1",
},
entry: [
{
import: "./src/index.ts",
html: { template: "./index.html" },
},
],
output: {
path: "./dist",
filename: "[name].[contenthash:6].js",
chunkFilename: "[name].[contenthash:8].js",
clean: true,
},
sourceMaps: false,
optimization: { minify: false },
});
Loading