@madebyseed/seed-cli-tools 2.3.1 → 2.4.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.
Files changed (100) hide show
  1. package/lib/commands/build.d.ts +2 -0
  2. package/lib/commands/build.js +30 -29
  3. package/lib/commands/build.js.map +1 -0
  4. package/lib/commands/deploy.d.ts +2 -0
  5. package/lib/commands/deploy.js +42 -30
  6. package/lib/commands/deploy.js.map +1 -0
  7. package/lib/commands/pull.d.ts +2 -0
  8. package/lib/commands/pull.js +39 -29
  9. package/lib/commands/pull.js.map +1 -0
  10. package/lib/commands/watch.d.ts +2 -0
  11. package/lib/commands/watch.js +44 -40
  12. package/lib/commands/watch.js.map +1 -0
  13. package/lib/commands/zip.d.ts +2 -0
  14. package/lib/commands/zip.js +23 -25
  15. package/lib/commands/zip.js.map +1 -0
  16. package/lib/config.d.ts +3 -0
  17. package/lib/config.js +21 -28
  18. package/lib/config.js.map +1 -0
  19. package/lib/gulpfile.d.ts +1 -0
  20. package/lib/gulpfile.js +26 -33
  21. package/lib/gulpfile.js.map +1 -0
  22. package/lib/tasks/build-assets.d.ts +1 -0
  23. package/lib/tasks/build-assets.js +80 -72
  24. package/lib/tasks/build-assets.js.map +1 -0
  25. package/lib/tasks/build-css.d.ts +1 -0
  26. package/lib/tasks/build-css.js +88 -82
  27. package/lib/tasks/build-css.js.map +1 -0
  28. package/lib/tasks/build-js.d.ts +1 -0
  29. package/lib/tasks/build-js.js +77 -83
  30. package/lib/tasks/build-js.js.map +1 -0
  31. package/lib/tasks/build-svg.d.ts +1 -0
  32. package/lib/tasks/build-svg.js +51 -54
  33. package/lib/tasks/build-svg.js.map +1 -0
  34. package/lib/tasks/build-utils.d.ts +1 -0
  35. package/lib/tasks/build-utils.js +68 -49
  36. package/lib/tasks/build-utils.js.map +1 -0
  37. package/lib/tasks/includes/config.d.ts +70 -0
  38. package/lib/tasks/includes/config.js +117 -163
  39. package/lib/tasks/includes/config.js.map +1 -0
  40. package/lib/tasks/includes/messages.d.ts +19 -0
  41. package/lib/tasks/includes/messages.js +80 -72
  42. package/lib/tasks/includes/messages.js.map +1 -0
  43. package/lib/tasks/includes/utilities.d.ts +71 -0
  44. package/lib/tasks/includes/utilities.js +127 -141
  45. package/lib/tasks/includes/utilities.js.map +1 -0
  46. package/lib/tasks/shopify-cli.d.ts +1 -0
  47. package/lib/tasks/shopify-cli.js +106 -93
  48. package/lib/tasks/shopify-cli.js.map +1 -0
  49. package/lib/tasks/watchers.d.ts +1 -0
  50. package/lib/tasks/watchers.js +29 -29
  51. package/lib/tasks/watchers.js.map +1 -0
  52. package/lib/types.d.ts +48 -0
  53. package/lib/types.js +3 -0
  54. package/lib/types.js.map +1 -0
  55. package/lib/utils.d.ts +90 -0
  56. package/lib/utils.js +194 -189
  57. package/lib/utils.js.map +1 -0
  58. package/package.json +36 -16
  59. package/src/commands/build.ts +39 -0
  60. package/src/commands/deploy.ts +70 -0
  61. package/src/commands/pull.ts +58 -0
  62. package/src/commands/watch.ts +72 -0
  63. package/src/commands/zip.ts +28 -0
  64. package/src/config.ts +28 -0
  65. package/src/gulpfile.ts +134 -0
  66. package/src/tasks/build-assets.ts +135 -0
  67. package/src/tasks/build-css.ts +129 -0
  68. package/src/tasks/build-js.ts +108 -0
  69. package/src/tasks/build-svg.ts +92 -0
  70. package/src/tasks/build-utils.ts +137 -0
  71. package/src/tasks/includes/config.ts +222 -0
  72. package/src/tasks/includes/messages.ts +157 -0
  73. package/src/tasks/includes/utilities.ts +170 -0
  74. package/src/tasks/shopify-cli.ts +197 -0
  75. package/src/tasks/watchers.ts +50 -0
  76. package/src/types/declarations.d.ts +72 -0
  77. package/src/types.ts +74 -0
  78. package/src/utils.ts +304 -0
  79. package/{src → src-legacy}/tasks/build-js.js +5 -6
  80. package/tsconfig.json +14 -0
  81. package/tsconfig.tsbuildinfo +1 -0
  82. package/.babelrc +0 -3
  83. package/.eslintrc +0 -8
  84. /package/{src → src-legacy}/commands/build.js +0 -0
  85. /package/{src → src-legacy}/commands/deploy.js +0 -0
  86. /package/{src → src-legacy}/commands/pull.js +0 -0
  87. /package/{src → src-legacy}/commands/watch.js +0 -0
  88. /package/{src → src-legacy}/commands/zip.js +0 -0
  89. /package/{src → src-legacy}/config.js +0 -0
  90. /package/{src → src-legacy}/gulpfile.js +0 -0
  91. /package/{src → src-legacy}/tasks/build-assets.js +0 -0
  92. /package/{src → src-legacy}/tasks/build-css.js +0 -0
  93. /package/{src → src-legacy}/tasks/build-svg.js +0 -0
  94. /package/{src → src-legacy}/tasks/build-utils.js +0 -0
  95. /package/{src → src-legacy}/tasks/includes/config.js +0 -0
  96. /package/{src → src-legacy}/tasks/includes/messages.js +0 -0
  97. /package/{src → src-legacy}/tasks/includes/utilities.js +0 -0
  98. /package/{src → src-legacy}/tasks/shopify-cli.js +0 -0
  99. /package/{src → src-legacy}/tasks/watchers.js +0 -0
  100. /package/{src → src-legacy}/utils.js +0 -0
@@ -0,0 +1,129 @@
1
+ import path from "path";
2
+ import gulp from "gulp";
3
+ import gulpSass from "gulp-sass";
4
+ import sass from "sass";
5
+ import postcss from "gulp-postcss";
6
+ import plumber from "gulp-plumber";
7
+ import chokidar from "chokidar";
8
+ import { glob } from "glob";
9
+ import { utimesSync } from "fs";
10
+ import config from "./includes/config";
11
+ import messages from "./includes/messages";
12
+ import utils from "./includes/utilities";
13
+
14
+ interface TailwindConfig {
15
+ mode?: string;
16
+ [key: string]: unknown;
17
+ }
18
+
19
+ const sassCompiler = gulpSass(sass);
20
+ const tailwindConfig: TailwindConfig = config.usesTailwind
21
+ ? require(path.join(config.themeRoot, config.tailwindConfig))
22
+ : {};
23
+
24
+ const assets: string[] =
25
+ config.usesTailwind || tailwindConfig.mode === "jit"
26
+ ? [
27
+ config.src.css,
28
+ config.src.scss,
29
+ config.src.sections,
30
+ config.src.layout,
31
+ config.src.snippets,
32
+ config.src.assets,
33
+ config.src.templates,
34
+ config.src.js,
35
+ config.src.icons,
36
+ config.tailwindConfig,
37
+ ]
38
+ : [config.src.css, config.src.scss, config.tailwindConfig];
39
+
40
+ /**
41
+ * Process css and tailwind
42
+ *
43
+ * @returns {Promise<void>}
44
+ * @private
45
+ */
46
+ function processCss(): Promise<void> {
47
+ return new Promise((resolve, reject) => {
48
+ gulp
49
+ .src(config.roots.css, { allowEmpty: true })
50
+ .pipe(plumber(utils.errorHandler))
51
+ .pipe(postcss(config.plugins.postcss))
52
+ .pipe(gulp.dest(config.dist.assets))
53
+ .on("finish", resolve)
54
+ .on("error", reject);
55
+ });
56
+ }
57
+
58
+ /**
59
+ * Process sass files
60
+ *
61
+ * @returns {Promise<void>}
62
+ * @private
63
+ */
64
+ function processSass(): Promise<void> {
65
+ return new Promise((resolve, reject) => {
66
+ gulp
67
+ .src(config.roots.scss, { allowEmpty: true })
68
+ .pipe(plumber(utils.errorHandler))
69
+ .pipe(sassCompiler())
70
+ .pipe(postcss(config.plugins.postcss))
71
+ .pipe(gulp.dest(config.dist.assets))
72
+ .on("finish", resolve)
73
+ .on("error", reject);
74
+ });
75
+ }
76
+
77
+ /**
78
+ * Touch CSS files to update their modification time
79
+ * This ensures Shopify's watcher detects the changes
80
+ */
81
+ function touchCssFiles(): void {
82
+ try {
83
+ const cssFiles = glob.sync(`${config.dist.assets}*.css`);
84
+ cssFiles.forEach((file) => {
85
+ // Update the file modification time to trigger Shopify's watcher
86
+ const now = new Date();
87
+ utimesSync(file, now, now);
88
+ messages.logFileEvent("touch", file);
89
+ });
90
+ } catch (error) {
91
+ console.error("Error touching CSS files:", error);
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Concatenate css via gulp-cssimport
97
+ *
98
+ * @function build:css
99
+ * @memberof seed-cli.tasks.build
100
+ * @static
101
+ */
102
+ gulp.task("build:css", () => {
103
+ return Promise.all([processCss(), processSass()]);
104
+ });
105
+
106
+ /**
107
+ * Watches css in the `/src` directory
108
+ *
109
+ * @function watch:css
110
+ * @memberof seed-cli.tasks.watch
111
+ * @static
112
+ */
113
+ gulp.task("watch:css", () => {
114
+ chokidar.watch(assets, { ignoreInitial: true }).on("all", (event, path) => {
115
+ const isCssFile = /\.s[ac]ss$/i.test(path);
116
+ // Don't log event twice
117
+ if (isCssFile) {
118
+ processSass();
119
+ messages.logFileEvent(event, path);
120
+ }
121
+
122
+ processCss();
123
+
124
+ // Important: Touch CSS files after processing to ensure Shopify detects changes
125
+ setTimeout(() => {
126
+ touchCssFiles();
127
+ }, 500);
128
+ });
129
+ });
@@ -0,0 +1,108 @@
1
+ import gulp from "gulp";
2
+ import gulpif from "gulp-if";
3
+ import uglifyjs from "uglify-js";
4
+ import composer from "gulp-uglify/composer";
5
+ import include from "gulp-include";
6
+ import plumber from "gulp-plumber";
7
+ import chokidar from "chokidar";
8
+ import { glob } from "glob";
9
+ import { utimesSync } from "fs";
10
+ import utils from "./includes/utilities";
11
+ import config from "./includes/config";
12
+ import messages from "./includes/messages";
13
+ // Using Console type from Node.js types
14
+ import type { Console } from "console";
15
+
16
+ const minify = composer(uglifyjs, console as Console);
17
+
18
+ interface MinifyOptions {
19
+ mangle: boolean;
20
+ compress: boolean;
21
+ }
22
+
23
+ function processThemeJs(): NodeJS.ReadWriteStream {
24
+ messages.logProcessFiles("build:js");
25
+
26
+ return gulp
27
+ .src([config.roots.js, `!${config.roots.vendorJs}`], { allowEmpty: true })
28
+ .pipe(plumber(utils.errorHandler))
29
+ .pipe(include({ separateInputs: true }))
30
+ .pipe(gulpif(config.optimize && !config.usesModuleBundler, minify()))
31
+ .pipe(gulp.dest(config.dist.assets));
32
+ }
33
+
34
+ function processVendorJs(): NodeJS.ReadWriteStream {
35
+ messages.logProcessFiles("build:vendor-js");
36
+ return gulp
37
+ .src(config.roots.vendorJs, { allowEmpty: true })
38
+ .pipe(plumber())
39
+ .pipe(include())
40
+ .pipe(
41
+ minify({
42
+ mangle: true,
43
+ compress: true,
44
+ } as MinifyOptions),
45
+ )
46
+ .pipe(gulp.dest(config.dist.assets));
47
+ }
48
+
49
+ /**
50
+ * Touch JS files to update their modification time
51
+ * This ensures Shopify's watcher detects the changes
52
+ */
53
+ function touchJsFiles(): void {
54
+ try {
55
+ const jsFiles = glob.sync(`${config.dist.assets}*.js`);
56
+ jsFiles.forEach((file) => {
57
+ // Update the file modification time to trigger Shopify's watcher
58
+ const now = new Date();
59
+ utimesSync(file, now, now);
60
+ messages.logFileEvent("touch", file);
61
+ });
62
+ } catch (error) {
63
+ console.error("Error touching JS files:", error);
64
+ }
65
+ }
66
+
67
+ gulp.task("build:js", () => {
68
+ return processThemeJs();
69
+ });
70
+
71
+ gulp.task("watch:js", () => {
72
+ chokidar
73
+ .watch(
74
+ [config.src.js, `!${config.roots.vendorJs}`, `!${config.src.vendorJs}`],
75
+ {
76
+ ignoreInitial: true,
77
+ },
78
+ )
79
+ .on("all", (event, path) => {
80
+ messages.logFileEvent(event, path);
81
+ processThemeJs();
82
+
83
+ setTimeout(() => {
84
+ touchJsFiles();
85
+ }, 500);
86
+ });
87
+ });
88
+
89
+ gulp.task("build:vendor-js", () => {
90
+ return processVendorJs();
91
+ });
92
+
93
+ gulp.task("watch:vendor-js", () => {
94
+ chokidar
95
+ .watch([config.roots.vendorJs, config.src.vendorJs], {
96
+ ignoreInitial: true,
97
+ })
98
+ .on("all", (event, path) => {
99
+ messages.logFileEvent(event, path);
100
+ const stream = processVendorJs();
101
+ stream.on("end", () => {
102
+ // Touch JS files after processing to ensure Shopify detects changes
103
+ setTimeout(() => {
104
+ touchJsFiles();
105
+ }, 500);
106
+ });
107
+ });
108
+ });
@@ -0,0 +1,92 @@
1
+ import gulp from "gulp";
2
+ import vinylPaths from "vinyl-paths";
3
+ import del from "del";
4
+ import size from "gulp-size";
5
+ import chokidar from "chokidar";
6
+ import extReplace from "gulp-ext-replace";
7
+ import plumber from "gulp-plumber";
8
+
9
+ import config from "./includes/config";
10
+ import utils from "./includes/utilities";
11
+ import messages from "./includes/messages";
12
+
13
+ /**
14
+ * Processing for SVGs prior to deployment - adds accessibility markup, and converts
15
+ * the file to a liquid snippet.
16
+ *
17
+ * @param {String|Array} files - glob/array of files to match & send to the stream
18
+ * @returns {Stream}
19
+ * @private
20
+ */
21
+ function processIcons(files: string | string[]): NodeJS.ReadWriteStream {
22
+ messages.logProcessFiles("build:svg");
23
+ return gulp
24
+ .src(files)
25
+ .pipe(plumber(utils.errorHandler))
26
+ .pipe(extReplace(".liquid"))
27
+ .pipe(
28
+ size({
29
+ showFiles: true,
30
+ pretty: true,
31
+ }),
32
+ )
33
+ .pipe(gulp.dest(config.dist.snippets));
34
+ }
35
+
36
+ /**
37
+ * Cleanup/remove liquid snippets from the `dist` directory during watch tasks if
38
+ * any underlying SVG files in the `src` folder have been removed.
39
+ *
40
+ * @param {String|Array} files - glob/array of files to match & send to the stream
41
+ * @returns {Stream}
42
+ * @private
43
+ */
44
+ function removeIcons(files: string[]): NodeJS.ReadWriteStream {
45
+ messages.logProcessFiles("remove:svg");
46
+ const mapFiles = files.map((file) => {
47
+ const distFile = file.replace("src/icons", "dist/snippets");
48
+ const snippetFile = distFile.replace(".svg", ".liquid");
49
+ return snippetFile;
50
+ });
51
+
52
+ return gulp
53
+ .src(mapFiles)
54
+ .pipe(plumber(utils.errorHandler))
55
+ .pipe(vinylPaths(del))
56
+ .pipe(
57
+ size({
58
+ showFiles: true,
59
+ pretty: true,
60
+ }),
61
+ );
62
+ }
63
+
64
+ /**
65
+ * Pre-processing for svg icons
66
+ *
67
+ * @function build:svg
68
+ * @memberof slate-cli.tasks.build
69
+ * @static
70
+ */
71
+ gulp.task("build:svg", () => {
72
+ return processIcons(config.src.icons);
73
+ });
74
+
75
+ /**
76
+ * Watches source svg icons for changes...
77
+ *
78
+ * @function watch:svg
79
+ * @memberof slate-cli.tasks.watch
80
+ * @static
81
+ */
82
+ gulp.task("watch:svg", () => {
83
+ const cache = utils.createEventCache();
84
+
85
+ chokidar
86
+ .watch([config.src.icons], { ignoreInitial: true })
87
+ .on("all", (event, path) => {
88
+ messages.logFileEvent(event, path);
89
+ cache.addEvent(event, path);
90
+ utils.processCache(cache, processIcons, removeIcons);
91
+ });
92
+ });
@@ -0,0 +1,137 @@
1
+ import gulp from "gulp";
2
+ import gulpif from "gulp-if";
3
+ import del from "del";
4
+ import size from "gulp-size";
5
+ import plumber from "gulp-plumber";
6
+
7
+ import config from "./includes/config";
8
+ import utils from "./includes/utilities";
9
+ import messages from "./includes/messages";
10
+ import { getProjectConfig } from "../utils";
11
+
12
+ const assetsPaths: string[] = [
13
+ config.src.assets,
14
+ config.src.templates,
15
+ config.src.sections,
16
+ config.src.snippets,
17
+ config.src.blocks,
18
+ config.src.locales,
19
+ config.src.config,
20
+ config.src.layout,
21
+ ];
22
+
23
+ /**
24
+ * Get theme settings assets to sync, respecting project config ignore list
25
+ */
26
+ function getThemeSettingsAssets(): string[] {
27
+ const defaultAssets = [
28
+ config.tmp.templates,
29
+ config.tmp.config,
30
+ config.tmp.sectionsJson,
31
+ config.tmp.blocksJson,
32
+ config.tmp.locales,
33
+ ];
34
+
35
+ // Convert ignore patterns to negated glob patterns
36
+ const ignorePatterns = getIgnorePatterns();
37
+
38
+ // Combine default assets with ignore patterns
39
+ return [...defaultAssets, ...ignorePatterns];
40
+ }
41
+
42
+ function getIgnorePatterns(): string[] {
43
+ const projectConfig = getProjectConfig(config.themeRoot);
44
+ if (!projectConfig?.pull?.ignoreFiles?.length) {
45
+ return [];
46
+ }
47
+ return projectConfig.pull.ignoreFiles.map((pattern) =>
48
+ pattern.startsWith("!") ? pattern : `!tmp/${pattern}`,
49
+ );
50
+ }
51
+
52
+ interface SrcOptions {
53
+ base?: string;
54
+ [key: string]: unknown;
55
+ }
56
+
57
+ /**
58
+ * Copies files from one fold to another, creating a new dir if doesn't exists and
59
+ * overwriting if it does exist
60
+ *
61
+ * @param {Array} files - files to copy
62
+ * @param {Object} srcOptions - second param for gulp.src function
63
+ * @param {String} dest - destination dir
64
+ * @returns {Stream}
65
+ * @private
66
+ */
67
+ function copyFiles(
68
+ files: string | string[],
69
+ srcOptions: SrcOptions,
70
+ dest: string,
71
+ log = false,
72
+ ): NodeJS.ReadWriteStream {
73
+ return gulp
74
+ .src(files, srcOptions)
75
+ .pipe(plumber(utils.errorHandler))
76
+ .pipe(gulpif(log, size({ showFiles: true, pretty: true })))
77
+ .pipe(gulp.dest(dest));
78
+ }
79
+
80
+ /**
81
+ * Clean up build dirs/files whenever doing a full/clean (re)build.
82
+ *
83
+ * @function build:clean
84
+ * @memberof slate-cli.tasks.build
85
+ * @static
86
+ */
87
+ gulp.task("clean", () => {
88
+ return del(["upload", "dist", "tmp", "src/*.zip", "*.zip"]);
89
+ });
90
+
91
+ /**
92
+ * Duplicates /src directory into a /tmp directory
93
+ *
94
+ * @function generate:tmp
95
+ * @memberof seed-cli.tasks.sync-settings
96
+ * @static
97
+ */
98
+ gulp.task("generate:tmp", () => {
99
+ messages.logProcessFiles("Generating tmp folder...");
100
+ return copyFiles(assetsPaths, { base: config.src.root }, config.tmp.root);
101
+ });
102
+
103
+ /**
104
+ * Synchronizes the theme settings of /tmp directory into our src directory
105
+ *
106
+ * @function sync-settings:tmp:src
107
+ * @memberof seed-cli.tasks.sync-settings
108
+ * @static
109
+ */
110
+ gulp.task("sync-settings:tmp:src", () => {
111
+ messages.logProcessFiles("Synchronizing /tmp theme settings with /src");
112
+ const ignorePatterns = getIgnorePatterns();
113
+ const themeSettingsAssets = getThemeSettingsAssets();
114
+ messages.logProcessFiles(
115
+ `Using ignore patterns from project config: ${JSON.stringify(ignorePatterns)}`,
116
+ );
117
+ return copyFiles(
118
+ themeSettingsAssets,
119
+ { base: config.tmp.root },
120
+ config.src.root,
121
+ );
122
+ });
123
+
124
+ /**
125
+ * Copies zip from dist to src
126
+ * @function copy:zip
127
+ * @memberof seed-cli.tasks.sync-settings
128
+ * @static
129
+ */
130
+ gulp.task("copy:zip", () => {
131
+ return copyFiles(
132
+ config.dist.zip,
133
+ { base: config.dist.root },
134
+ config.themeRoot,
135
+ true,
136
+ );
137
+ });
@@ -0,0 +1,222 @@
1
+ import { join } from "path";
2
+ import debug from "debug";
3
+ import findRoot from "find-root";
4
+ import tailwindcss from "tailwindcss";
5
+ import cssnano from "cssnano";
6
+ import pxtorem from "postcss-pxtorem";
7
+ import reporter from "postcss-reporter";
8
+ import minimist from "minimist";
9
+ import { existsSync } from "fs";
10
+ import autoprefixer from "autoprefixer";
11
+ import postcssImport from "postcss-import";
12
+
13
+ const logger = debug("seed-tools");
14
+ const argv = minimist(process.argv.slice(2));
15
+ const themeRoot = findRoot(process.cwd());
16
+ const tailwindConfig = "tailwind.config.js";
17
+
18
+ interface PackageJson {
19
+ "bundle-js"?: boolean;
20
+ [key: string]: unknown;
21
+ }
22
+
23
+ let pkg: PackageJson = {};
24
+
25
+ try {
26
+ pkg = require(join(themeRoot, "package.json"));
27
+ } catch (err) {
28
+ logger(err);
29
+ }
30
+
31
+ interface PathConfig {
32
+ root: string;
33
+ js: string;
34
+ vendorJs: string;
35
+ json: string;
36
+ css: string;
37
+ scss: string;
38
+ cssLint: string;
39
+ vendorCss: string;
40
+ assets: string;
41
+ icons: string;
42
+ templates: string;
43
+ snippets: string;
44
+ sections: string;
45
+ blocks: string;
46
+ locales: string;
47
+ config: string;
48
+ layout: string;
49
+ zip: string;
50
+ }
51
+
52
+ interface TmpPathConfig extends PathConfig {
53
+ sectionsJson: string;
54
+ blocksJson: string;
55
+ }
56
+
57
+ interface DistPathConfig {
58
+ root: string;
59
+ assets: string;
60
+ snippets: string;
61
+ sections: string;
62
+ blocks: string;
63
+ layout: string;
64
+ templates: string;
65
+ locales: string;
66
+ zip: string;
67
+ }
68
+
69
+ interface RootsConfig {
70
+ js: string;
71
+ vendorJs: string;
72
+ css: string;
73
+ scss: string;
74
+ }
75
+
76
+ interface PluginsConfig {
77
+ postcss: any[];
78
+ }
79
+
80
+ interface BuildConfig {
81
+ environment: string;
82
+ store: string | null;
83
+ storePassword: string | null;
84
+ optimize: boolean;
85
+ nodelete: boolean;
86
+ themeRoot: string;
87
+ packageJson: PackageJson;
88
+ tailwindConfig: string;
89
+ usesTailwind: boolean;
90
+ usesModuleBundler: boolean;
91
+ seedConfig: string;
92
+ shopifyIgnore: string;
93
+ src: PathConfig;
94
+ tmp: TmpPathConfig;
95
+ dist: DistPathConfig;
96
+ roots: RootsConfig;
97
+ plugins: PluginsConfig;
98
+ }
99
+
100
+ const config: BuildConfig = {
101
+ environment:
102
+ argv.environment === "undefined" || !argv.environment
103
+ ? "development"
104
+ : argv.environment,
105
+ store: argv.store === "undefined" || !argv.store ? null : argv.store,
106
+ storePassword:
107
+ argv["store-password"] === "undefined" || !argv["store-password"]
108
+ ? null
109
+ : argv["store-password"],
110
+ optimize: !argv["skip-optimizations"],
111
+ nodelete: !argv["delete"],
112
+ themeRoot,
113
+ packageJson: pkg,
114
+ tailwindConfig,
115
+ usesTailwind: existsSync(join(themeRoot, tailwindConfig)),
116
+ usesModuleBundler: !!pkg["bundle-js"],
117
+ seedConfig: "seed.config.js",
118
+ shopifyIgnore: join(themeRoot, ".shopifyignore"),
119
+
120
+ src: {
121
+ root: "src/",
122
+ js: "src/scripts/**/*.{js,js.liquid}",
123
+ vendorJs: "src/scripts/vendor/*.js",
124
+ json: "src/**/*.json",
125
+ css: "src/styles/**/*.css",
126
+ scss: "src/styles/**/*.scss",
127
+ cssLint: "src/styles/**/*.{css,scss}",
128
+ vendorCss: "src/styles/vendor/*.{css,scss}",
129
+ assets: "src/assets/**/*",
130
+ icons: "src/icons/**/*.svg",
131
+ templates: "src/templates/**/*",
132
+ snippets: "src/snippets/*",
133
+ sections: "src/sections/*",
134
+ blocks: "src/blocks/*",
135
+ locales: "src/locales/*",
136
+ config: "src/config/*",
137
+ layout: "src/layout/*",
138
+ zip: "src/**/*.zip",
139
+ },
140
+
141
+ tmp: {
142
+ root: "tmp/",
143
+ js: "tmp/scripts/**/*.{js,js.liquid}",
144
+ vendorJs: "tmp/scripts/vendor/*.js",
145
+ json: "tmp/**/*.json",
146
+ css: "tmp/styles/**/*.css",
147
+ scss: "tmp/styles/**/*.scss",
148
+ cssLint: "tmp/styles/**/*.{css,scss}",
149
+ vendorCss: "tmp/styles/vendor/*.{css,scss}",
150
+ assets: "tmp/assets/**/*",
151
+ icons: "tmp/icons/**/*.svg",
152
+ templates: "tmp/templates/**/*",
153
+ snippets: "tmp/snippets/*",
154
+ sections: "tmp/sections/*",
155
+ sectionsJson: "tmp/sections/*.json",
156
+ blocks: "tmp/blocks/*",
157
+ blocksJson: "tmp/blocks/*.json",
158
+ locales: "tmp/locales/*",
159
+ config: "tmp/config/*",
160
+ layout: "tmp/layout/*",
161
+ zip: "tmp/**/*.zip",
162
+ },
163
+
164
+ dist: {
165
+ root: "dist/",
166
+ assets: "dist/assets/",
167
+ snippets: "dist/snippets/",
168
+ sections: "dist/sections/",
169
+ blocks: "dist/blocks",
170
+ layout: "dist/layout/",
171
+ templates: "dist/templates/",
172
+ locales: "dist/locales/",
173
+ zip: "dist/*.zip",
174
+ },
175
+
176
+ roots: {
177
+ js: "src/scripts/*.{js,js.liquid}",
178
+ vendorJs: "src/scripts/vendor.js",
179
+ css: "src/styles/*.css",
180
+ scss: "src/styles/*.scss",
181
+ },
182
+
183
+ plugins: {
184
+ postcss: [postcssImport],
185
+ },
186
+ };
187
+
188
+ if (config.usesTailwind) {
189
+ config.plugins.postcss.push(
190
+ tailwindcss({ config: join(themeRoot, tailwindConfig) }),
191
+ );
192
+ }
193
+
194
+ config.plugins.postcss.push(autoprefixer);
195
+
196
+ config.plugins.postcss.push(
197
+ pxtorem({
198
+ rootValue: 16,
199
+ unitPrecision: 5,
200
+ propList: ["*"],
201
+ selectorBlackList: [],
202
+ replace: true,
203
+ mediaQuery: true,
204
+ exclude: /node_modules/i,
205
+ }),
206
+ );
207
+
208
+ if (config.optimize) {
209
+ config.plugins.postcss.push(cssnano({ preset: "default" }));
210
+ }
211
+
212
+ config.plugins.postcss.push(reporter({ clearReportedMessages: true }));
213
+
214
+ export default config;
215
+ export type {
216
+ BuildConfig,
217
+ PathConfig,
218
+ TmpPathConfig,
219
+ DistPathConfig,
220
+ RootsConfig,
221
+ PluginsConfig,
222
+ };