@akqa-denmark/shopify-theme-build 0.1.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/dist/vite.js ADDED
@@ -0,0 +1,116 @@
1
+ import {
2
+ ASSET_NAMING,
3
+ getStorePaths,
4
+ log,
5
+ orchestrate,
6
+ resolveConfig,
7
+ resolveStore
8
+ } from "./chunk-JXQLZXJ2.js";
9
+
10
+ // src/vite.ts
11
+ import { join } from "path";
12
+ import { defineConfig, mergeConfig } from "vite";
13
+
14
+ // src/plugins/schema-watcher.ts
15
+ function createSchemaWatcherPlugin(config, store) {
16
+ const paths = getStorePaths(config, store);
17
+ let debounceTimer = null;
18
+ const DEBOUNCE_MS = 3e3;
19
+ return {
20
+ name: "shopify-schema-watcher",
21
+ configureServer(server) {
22
+ server.watcher.add(paths.schemasDir);
23
+ server.watcher.on("change", (file) => {
24
+ if (!file.startsWith(paths.schemasDir)) return;
25
+ if (!file.endsWith(".ts")) return;
26
+ if (file.includes("index.ts")) return;
27
+ if (debounceTimer) clearTimeout(debounceTimer);
28
+ debounceTimer = setTimeout(async () => {
29
+ log("info", `Schema changed: ${file}`);
30
+ try {
31
+ await orchestrate({ store, config });
32
+ log("success", "Schema rebuild complete");
33
+ } catch (error) {
34
+ log("error", `Schema rebuild failed: ${error}`);
35
+ }
36
+ }, DEBOUNCE_MS);
37
+ });
38
+ log("info", `Schema watcher active for: ${paths.schemasDir}`);
39
+ }
40
+ };
41
+ }
42
+
43
+ // src/vite.ts
44
+ async function createViteConfig(overrides) {
45
+ const config = await resolveConfig();
46
+ const store = resolveStore(config);
47
+ const paths = getStorePaths(config, store);
48
+ let tailwindPlugin = null;
49
+ try {
50
+ const tw = await import("@tailwindcss/vite");
51
+ tailwindPlugin = (tw.default || tw)();
52
+ } catch {
53
+ }
54
+ const shopify = (await import("vite-plugin-shopify")).default;
55
+ const fullReload = (await import("vite-plugin-full-reload")).default;
56
+ const baseConfig = defineConfig({
57
+ base: "",
58
+ cacheDir: join(config.rootDir, ".cache/vite", store),
59
+ plugins: [
60
+ shopify({
61
+ themeRoot: paths.themeDir,
62
+ sourceCodeDir: paths.srcDir,
63
+ entrypointsDir: paths.entrypointsDir
64
+ }),
65
+ createSchemaWatcherPlugin(config, store),
66
+ fullReload(
67
+ [
68
+ `${paths.themeDir}/**/*.{liquid,json}`,
69
+ `${paths.schemasDir}/**/*.ts`
70
+ ],
71
+ { delay: 100 }
72
+ ),
73
+ ...tailwindPlugin ? [tailwindPlugin] : []
74
+ ],
75
+ resolve: {
76
+ tsconfigPaths: true
77
+ },
78
+ css: {
79
+ devSourcemap: true
80
+ },
81
+ build: {
82
+ outDir: join(paths.themeDir, "assets"),
83
+ emptyOutDir: true,
84
+ rolldownOptions: {
85
+ output: {
86
+ assetFileNames: (assetInfo) => {
87
+ const name = assetInfo.name || "";
88
+ if (/\.(woff2|woff|ttf|otf|eot)$/i.test(name)) return ASSET_NAMING.fonts;
89
+ if (/\.css$/i.test(name)) return ASSET_NAMING.css;
90
+ if (/\.js$/i.test(name)) return ASSET_NAMING.js;
91
+ return ASSET_NAMING.other;
92
+ },
93
+ entryFileNames: ASSET_NAMING.entry
94
+ }
95
+ }
96
+ },
97
+ server: {
98
+ port: config.vite.port,
99
+ host: "0.0.0.0",
100
+ cors: { origin: true, credentials: true },
101
+ watch: {
102
+ ignored: ["**/node_modules/**", "**/.git/**", "**/.cache/**"]
103
+ },
104
+ hmr: {
105
+ protocol: "ws",
106
+ host: "localhost",
107
+ port: config.vite.port
108
+ }
109
+ },
110
+ ...config.vite.bundledDev ? { experimental: { bundledDev: true } } : {}
111
+ });
112
+ return overrides ? mergeConfig(baseConfig, overrides) : baseConfig;
113
+ }
114
+ export {
115
+ createViteConfig
116
+ };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@akqa-denmark/shopify-theme-build",
3
+ "version": "0.1.0",
4
+ "description": "Shopify theme build pipeline — schema generation, locale merging, and Vite config factory",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./vite": {
15
+ "types": "./dist/vite.d.ts",
16
+ "import": "./dist/vite.js"
17
+ }
18
+ },
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "bin": {
22
+ "shopify-build": "bin/shopify-build.js"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "bin"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "dev": "tsup --watch",
31
+ "type-check": "tsc --noEmit",
32
+ "release": "npx tsx scripts/release.ts",
33
+ "release:dry": "npx tsx scripts/release.ts --dry-run",
34
+ "prepublishOnly": "npm run build"
35
+ },
36
+ "dependencies": {
37
+ "chalk": "^5.4.0",
38
+ "jiti": "^2.4.0"
39
+ },
40
+ "peerDependencies": {
41
+ "@tailwindcss/vite": ">=4.0.0",
42
+ "vite": "^8.0.0",
43
+ "vite-plugin-full-reload": ">=1.0.0",
44
+ "vite-plugin-shopify": ">=4.0.0"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "@tailwindcss/vite": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "devDependencies": {
52
+ "@inquirer/prompts": "^8.5.2",
53
+ "@types/node": "^22.0.0",
54
+ "tsup": "^8.0.0",
55
+ "tsx": "^4.22.4",
56
+ "typescript": "^5.7.0",
57
+ "vite": "^8.0.0",
58
+ "vite-plugin-full-reload": "^1.2.0",
59
+ "vite-plugin-shopify": "^4.0.0"
60
+ },
61
+ "keywords": [
62
+ "shopify",
63
+ "theme",
64
+ "vite",
65
+ "build",
66
+ "schema"
67
+ ],
68
+ "license": "MIT",
69
+ "author": "AKQA Denmark",
70
+ "publishConfig": {
71
+ "access": "public"
72
+ }
73
+ }