@roots/bud-build 5.7.7 → 5.8.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 (45) hide show
  1. package/lib/cjs/Build/config/builder.js +15 -46
  2. package/lib/cjs/Build/config/filenameFormat.js +4 -4
  3. package/lib/cjs/Build/index.js +25 -43
  4. package/lib/cjs/Item/index.js +9 -6
  5. package/lib/cjs/Loader/index.js +8 -5
  6. package/lib/cjs/Rule/index.js +28 -15
  7. package/lib/cjs/index.js +14 -14
  8. package/lib/cjs/{Build/items.js → items.js} +11 -4
  9. package/lib/cjs/{Build/loaders.js → loaders.js} +3 -1
  10. package/lib/cjs/rules.js +195 -0
  11. package/lib/cjs/shared/Base.js +13 -2
  12. package/lib/tsconfig.tsbuildinfo +1 -1
  13. package/package.json +37 -11
  14. package/types/Build/config/builder.d.ts +4 -4
  15. package/types/Build/config/builder.d.ts.map +1 -1
  16. package/types/Build/config/filenameFormat.d.ts +3 -3
  17. package/types/Build/config/filenameFormat.d.ts.map +1 -1
  18. package/types/Build/index.d.ts +11 -17
  19. package/types/Build/index.d.ts.map +1 -1
  20. package/types/Item/index.d.ts +15 -14
  21. package/types/Item/index.d.ts.map +1 -1
  22. package/types/Loader/index.d.ts +9 -8
  23. package/types/Loader/index.d.ts.map +1 -1
  24. package/types/Rule/index.d.ts +29 -30
  25. package/types/Rule/index.d.ts.map +1 -1
  26. package/types/index.d.ts +9 -9
  27. package/types/index.d.ts.map +1 -1
  28. package/types/items.d.ts +73 -0
  29. package/types/items.d.ts.map +1 -0
  30. package/types/loaders.d.ts +47 -0
  31. package/types/loaders.d.ts.map +1 -0
  32. package/types/rules.d.ts +84 -0
  33. package/types/rules.d.ts.map +1 -0
  34. package/types/shared/Base.d.ts +7 -7
  35. package/types/shared/Base.d.ts.map +1 -1
  36. package/lib/cjs/Build/config/builder.unwrap.js +0 -35
  37. package/lib/cjs/Build/rules.js +0 -174
  38. package/types/Build/config/builder.unwrap.d.ts +0 -19
  39. package/types/Build/config/builder.unwrap.d.ts.map +0 -1
  40. package/types/Build/items.d.ts +0 -67
  41. package/types/Build/items.d.ts.map +0 -1
  42. package/types/Build/loaders.d.ts +0 -46
  43. package/types/Build/loaders.d.ts.map +0 -1
  44. package/types/Build/rules.d.ts +0 -84
  45. package/types/Build/rules.d.ts.map +0 -1
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toml = exports.xml = exports.csv = exports.html = exports.yml = exports.json = exports.font = exports.svg = exports.webp = exports.image = exports.cssModule = exports.css = exports.js = void 0;
4
+ const bud_support_1 = require("@roots/bud-support");
5
+ /**
6
+ * .js rule
7
+ *
8
+ * @public
9
+ */
10
+ const js = (app) => app.build
11
+ .makeRule()
12
+ .setTest(({ hooks }) => hooks.filter('pattern.js'))
13
+ .setInclude([app => app.path('@src')])
14
+ .setUse([]);
15
+ exports.js = js;
16
+ /**
17
+ * .css rule
18
+ *
19
+ * @public
20
+ */
21
+ const css = (app) => app.build
22
+ .makeRule()
23
+ .setTest(({ hooks }) => hooks.filter('pattern.css'))
24
+ .setInclude([app => app.path('@src')])
25
+ .setUse([`precss`, `css`]);
26
+ exports.css = css;
27
+ /**
28
+ * .module.css rule
29
+ *
30
+ * @public
31
+ */
32
+ const cssModule = (app) => app.build
33
+ .makeRule()
34
+ .setTest(({ hooks }) => hooks.filter('pattern.cssModule'))
35
+ .setInclude([app => app.path('@src')])
36
+ .setUse([`precss`, `cssModule`]);
37
+ exports.cssModule = cssModule;
38
+ /**
39
+ * .jpg, .jpeg, .png, .gif rule
40
+ *
41
+ * @public
42
+ */
43
+ const image = (app) => app.build
44
+ .makeRule()
45
+ .setTest(({ hooks }) => hooks.filter('pattern.image'))
46
+ .setInclude([app => app.path('@src')])
47
+ .setType('asset/resource')
48
+ .setGenerator(app => ({
49
+ filename: app.hooks.filter('feature.hash')
50
+ ? 'images/'
51
+ .concat(app.hooks.filter('value.hashFormat'))
52
+ .concat('[ext]')
53
+ : 'images/'
54
+ .concat(app.hooks.filter('value.fileFormat'))
55
+ .concat('[ext]'),
56
+ }));
57
+ exports.image = image;
58
+ /**
59
+ * .webp assets factorry
60
+ *
61
+ * @remarks
62
+ * Returns {@link Rule} for `asset/resource`
63
+ *
64
+ * @public
65
+ */
66
+ const webp = (app) => app.build
67
+ .makeRule()
68
+ .setTest(({ hooks }) => hooks.filter('pattern.webp'))
69
+ .setInclude([app => app.path('@src')])
70
+ .setType('asset/resource')
71
+ .setGenerator(app => ({
72
+ filename: app.hooks.filter('feature.hash')
73
+ ? 'images/'
74
+ .concat(app.hooks.filter('value.hashFormat'))
75
+ .concat('[ext]')
76
+ : 'images/'
77
+ .concat(app.hooks.filter('value.fileFormat'))
78
+ .concat('[ext]'),
79
+ }));
80
+ exports.webp = webp;
81
+ /**
82
+ * Returns {@link Rule} for `.woff`/`.otf` handling
83
+ * .svg rule
84
+ *
85
+ * @public
86
+ */
87
+ const svg = (app) => app.build
88
+ .makeRule()
89
+ .setTest(({ hooks }) => hooks.filter('pattern.svg'))
90
+ .setInclude([app => app.path('@src')])
91
+ .setType('asset/resource')
92
+ .setGenerator(app => ({
93
+ filename: app.hooks.filter('feature.hash')
94
+ ? 'svg/'
95
+ .concat(app.hooks.filter('value.hashFormat'))
96
+ .concat('[ext]')
97
+ : 'svg/'
98
+ .concat(app.hooks.filter('value.fileFormat'))
99
+ .concat('[ext]'),
100
+ }));
101
+ exports.svg = svg;
102
+ /**
103
+ * .woff, .woff2, .otf rule
104
+ *
105
+ * @public
106
+ */
107
+ const font = (app) => app.build
108
+ .makeRule()
109
+ .setType('asset')
110
+ .setTest(({ hooks }) => hooks.filter('pattern.font'))
111
+ .setInclude([app => app.path('@src')])
112
+ .setGenerator(app => ({
113
+ filename: app.hooks.filter('feature.hash')
114
+ ? 'fonts/'
115
+ .concat(app.hooks.filter('value.hashFormat'))
116
+ .concat('[ext]')
117
+ : 'fonts/'
118
+ .concat(app.hooks.filter('value.fileFormat'))
119
+ .concat('[ext]'),
120
+ }));
121
+ exports.font = font;
122
+ /**
123
+ * Returns {@link Rule} for `.jsonc` handling
124
+ *
125
+ * @public
126
+ */
127
+ const json = (app) => app.build
128
+ .makeRule()
129
+ .setType('json')
130
+ .setInclude([app => app.path()])
131
+ .setExclude([app => app.path('@modules')])
132
+ .setTest(({ hooks }) => hooks.filter('pattern.json'))
133
+ .setParser({ parse: bud_support_1.json5.parse });
134
+ exports.json = json;
135
+ /**
136
+ * Returns {@link Rule} for `.yml` / `.yaml` handling
137
+ *
138
+ * @public
139
+ */
140
+ const yml = (app) => app.build
141
+ .makeRule()
142
+ .setInclude([app => app.path()])
143
+ .setExclude([app => app.path('@modules')])
144
+ .setTest(({ hooks }) => hooks.filter('pattern.yml'))
145
+ .setUse(['yml']);
146
+ exports.yml = yml;
147
+ /**
148
+ * Returns {@link Rule} for `.html` handling
149
+ *
150
+ * @public
151
+ */
152
+ const html = (app) => app.build
153
+ .makeRule()
154
+ .setInclude([app => app.path()])
155
+ .setExclude([app => app.path('@modules')])
156
+ .setTest(({ hooks }) => hooks.filter('pattern.html'))
157
+ .setUse([`html`]);
158
+ exports.html = html;
159
+ /**
160
+ * Returns {@link Rule} for `.csv` handling
161
+ *
162
+ * @public
163
+ */
164
+ const csv = (app) => app.build
165
+ .makeRule()
166
+ .setInclude([app => app.path()])
167
+ .setExclude([app => app.path('@modules')])
168
+ .setTest(({ hooks }) => hooks.filter('pattern.csv'))
169
+ .setUse([`csv`]);
170
+ exports.csv = csv;
171
+ /**
172
+ * Returns {@link Rule} for `.xml` handling
173
+ *
174
+ * @public
175
+ */
176
+ const xml = (app) => app.build
177
+ .makeRule()
178
+ .setInclude([app => app.path()])
179
+ .setExclude([app => app.path('@modules')])
180
+ .setTest(({ hooks }) => hooks.filter('pattern.xml'))
181
+ .setUse([`xml`]);
182
+ exports.xml = xml;
183
+ /**
184
+ * Returns {@link Rule} for `.toml` handling
185
+ *
186
+ * @public
187
+ */
188
+ const toml = (app) => app.build
189
+ .makeRule()
190
+ .setType('json')
191
+ .setInclude([app => app.path()])
192
+ .setExclude([app => app.path('@modules')])
193
+ .setTest(({ hooks }) => hooks.filter('pattern.html'))
194
+ .setParser({ parse: bud_support_1.toml.parse });
195
+ exports.toml = toml;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Base = void 0;
4
9
  const bud_support_1 = require("@roots/bud-support");
5
10
  const { isFunction } = bud_support_1.lodash;
6
11
  class Base {
@@ -17,4 +22,10 @@ class Base {
17
22
  return isFunction(input) ? input(this.app, ...options) : input;
18
23
  }
19
24
  }
20
- exports.Base = Base;
25
+ __decorate([
26
+ bud_support_1.bind
27
+ ], Base.prototype, "wrap", null);
28
+ __decorate([
29
+ bud_support_1.bind
30
+ ], Base.prototype, "unwrap", null);
31
+ exports.default = Base;