@rootreeweb/rt-webpack-helper 4.1.1

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 (42) hide show
  1. package/README.md +20 -0
  2. package/dist/esm/base.d.ts +20 -0
  3. package/dist/esm/base.d.ts.map +1 -0
  4. package/dist/esm/base.js +109 -0
  5. package/dist/esm/base.js.map +1 -0
  6. package/dist/esm/cssConfig.d.ts +9 -0
  7. package/dist/esm/cssConfig.d.ts.map +1 -0
  8. package/dist/esm/cssConfig.js +11 -0
  9. package/dist/esm/cssConfig.js.map +1 -0
  10. package/dist/esm/devConfig.d.ts +18 -0
  11. package/dist/esm/devConfig.d.ts.map +1 -0
  12. package/dist/esm/devConfig.js +38 -0
  13. package/dist/esm/devConfig.js.map +1 -0
  14. package/dist/esm/getPlugins.d.ts +10 -0
  15. package/dist/esm/getPlugins.d.ts.map +1 -0
  16. package/dist/esm/getPlugins.js +30 -0
  17. package/dist/esm/getPlugins.js.map +1 -0
  18. package/dist/esm/getRules.d.ts +10 -0
  19. package/dist/esm/getRules.d.ts.map +1 -0
  20. package/dist/esm/getRules.js +103 -0
  21. package/dist/esm/getRules.js.map +1 -0
  22. package/dist/esm/index.d.ts +4 -0
  23. package/dist/esm/index.d.ts.map +1 -0
  24. package/dist/esm/index.js +4 -0
  25. package/dist/esm/index.js.map +1 -0
  26. package/dist/esm/outputOptions.d.ts +10 -0
  27. package/dist/esm/outputOptions.d.ts.map +1 -0
  28. package/dist/esm/outputOptions.js +16 -0
  29. package/dist/esm/outputOptions.js.map +1 -0
  30. package/dist/esm/postcssProtectSupports.d.ts +25 -0
  31. package/dist/esm/postcssProtectSupports.d.ts.map +1 -0
  32. package/dist/esm/postcssProtectSupports.js +59 -0
  33. package/dist/esm/postcssProtectSupports.js.map +1 -0
  34. package/dist/esm/prefixPatcher.d.ts +9 -0
  35. package/dist/esm/prefixPatcher.d.ts.map +1 -0
  36. package/dist/esm/prefixPatcher.js +11 -0
  37. package/dist/esm/prefixPatcher.js.map +1 -0
  38. package/dist/esm/types.d.ts +20 -0
  39. package/dist/esm/types.d.ts.map +1 -0
  40. package/dist/esm/types.js +2 -0
  41. package/dist/esm/types.js.map +1 -0
  42. package/package.json +85 -0
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @rootreeweb/rt-webpack-helper
2
+
3
+ ## What is This?
4
+
5
+ @rootreeweb/rt-webpack-helper is a JavaScript package for generating standardized webpack configurations for projects.
6
+ There are three different base options to choose from:
7
+
8
+ - `getWebpackConfig` Returns a configuration for bundling web page scripts and styles for use in-browser.
9
+ This is the most commonly used option.
10
+ - `getCssConfig` Is a modified version of `getWebpackConfig` that is specialized for generating stylesheets only.
11
+ This is useful for scenarios in which the JavaScript portion of the project is not being bundled for browsers.
12
+ An example of this would be when creating a component library such as @rootreeweb/ui.
13
+ - `getWebpackDevConfig` Returns a configuration designed for testing JavaScript based apps locally.
14
+ It takes an HTML page, and a script entry point. It provides a local development server with hot-module-reload.
15
+ An example use case for this would be the aforementioned @rootreeweb/ui.
16
+ That library utilizes this configuration to give component authors a live view of the components they are working on.
17
+
18
+ ## Usage
19
+
20
+ Usage instructions can be found in the [Bundling With Webpack](https://docs.cappy.rootree.ca/guides/webpack/) guide.
@@ -0,0 +1,20 @@
1
+ import type { EntryObject, Configuration as WebpackConfiguration } from "webpack";
2
+ import { type GetConfigOptions, type OutputOptions } from "./types.js";
3
+ /**
4
+ * Creates the name of an output file.
5
+ *
6
+ * @param postfix The file postfix. Ex. `chunk`
7
+ * @param extension The file extension. Ex. `js`
8
+ * @param options The config options pertaining to hashing and filenaming.
9
+ * @returns The output file name to use.
10
+ */
11
+ export declare function getOutputName(postfix: string, extension: string, options?: OutputOptions): string;
12
+ /**
13
+ * Get the webpack configuration.
14
+ *
15
+ * @param entry The entry object to use.
16
+ * @param options The options for the configuration.
17
+ * @returns The webpack configuration.
18
+ */
19
+ export declare function getWebpackConfig(entry?: EntryObject, options?: GetConfigOptions): WebpackConfiguration;
20
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,WAAW,EACX,aAAa,IAAI,oBAAoB,EACrC,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC5B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,aAAa,GACrB,MAAM,CAUR;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,CAAC,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,gBAAgB,GACxB,oBAAoB,CA8CtB"}
@@ -0,0 +1,109 @@
1
+ import path from "path";
2
+ import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
3
+ import { getPlugins } from "./getPlugins.js";
4
+ import { getRules } from "./getRules.js";
5
+ import { getOutputOptions } from "./outputOptions.js";
6
+ import {} from "./types.js";
7
+ /**
8
+ * Creates the name of an output file.
9
+ *
10
+ * @param postfix The file postfix. Ex. `chunk`
11
+ * @param extension The file extension. Ex. `js`
12
+ * @param options The config options pertaining to hashing and filenaming.
13
+ * @returns The output file name to use.
14
+ */
15
+ export function getOutputName(postfix, extension, options) {
16
+ const { useHash, usePostfix } = getOutputOptions(options);
17
+ let name = "[name]";
18
+ if (useHash) {
19
+ name += ".[contenthash]";
20
+ }
21
+ if (usePostfix && postfix) {
22
+ name += "." + postfix;
23
+ }
24
+ return name + "." + extension;
25
+ }
26
+ /**
27
+ * Get the webpack configuration.
28
+ *
29
+ * @param entry The entry object to use.
30
+ * @param options The options for the configuration.
31
+ * @returns The webpack configuration.
32
+ */
33
+ export function getWebpackConfig(entry, options) {
34
+ const { additionalExtensions = [], aliases, devtool = "source-map", outputPath = path.resolve("dist"), } = options ?? {};
35
+ const extensions = [
36
+ ".tsx",
37
+ ".ts",
38
+ ".js",
39
+ ".css",
40
+ ".scss",
41
+ ...additionalExtensions,
42
+ ];
43
+ const resolve = {
44
+ extensionAlias: {
45
+ ".js": [".js", ".ts", ".tsx"],
46
+ },
47
+ extensions,
48
+ };
49
+ if (aliases) {
50
+ resolve.alias = aliases;
51
+ }
52
+ const baseConfig = {
53
+ devtool,
54
+ module: {
55
+ rules: getRules(options),
56
+ },
57
+ output: {
58
+ chunkFilename: getOutputName("chunk", "js", options),
59
+ filename: getOutputName("bundle", "js", options),
60
+ path: outputPath,
61
+ },
62
+ plugins: getPlugins(options),
63
+ resolve,
64
+ };
65
+ const optimization = getOptimizationOptions(options);
66
+ if (optimization) {
67
+ baseConfig.optimization = optimization;
68
+ }
69
+ if (entry) {
70
+ baseConfig.entry = entry;
71
+ }
72
+ return baseConfig;
73
+ }
74
+ /**
75
+ * Get the options pertaining to optimization.
76
+ *
77
+ * @param options The output options.
78
+ * @returns The optimization settings.
79
+ */
80
+ function getOptimizationOptions(options) {
81
+ const { optimize } = getOutputOptions(options);
82
+ return optimize
83
+ ? {
84
+ minimizer: [`...`, new CssMinimizerPlugin()],
85
+ sideEffects: true,
86
+ splitChunks: {
87
+ automaticNameDelimiter: "~",
88
+ cacheGroups: {
89
+ default: {
90
+ minChunks: 2,
91
+ priority: -20,
92
+ reuseExistingChunk: true,
93
+ },
94
+ defaultVendors: {
95
+ priority: -10,
96
+ test: /[\\/]node_modules[\\/]/,
97
+ },
98
+ },
99
+ enforceSizeThreshold: 50000,
100
+ maxAsyncRequests: 30,
101
+ maxInitialRequests: 30,
102
+ minChunks: 1,
103
+ minSize: 20000,
104
+ },
105
+ usedExports: true,
106
+ }
107
+ : undefined;
108
+ }
109
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,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O,EAAE,KAAK;aACd;YACD,WAAW,EAAE,IAAI;SACjB;QACF,CAAC,CAAC,SAAS,CAAC;AACd,CAAC","sourcesContent":["import path from \"path\";\nimport CssMinimizerPlugin from \"css-minimizer-webpack-plugin\";\nimport type {\n\tEntryObject,\n\tConfiguration as WebpackConfiguration,\n} from \"webpack\";\n\nimport { getPlugins } from \"./getPlugins.js\";\nimport { getRules } from \"./getRules.js\";\nimport { getOutputOptions } from \"./outputOptions.js\";\nimport { type GetConfigOptions, type OutputOptions } from \"./types.js\";\n\n/**\n * Creates the name of an output file.\n *\n * @param postfix The file postfix. Ex. `chunk`\n * @param extension The file extension. Ex. `js`\n * @param options The config options pertaining to hashing and filenaming.\n * @returns The output file name to use.\n */\nexport function getOutputName(\n\tpostfix: string,\n\textension: string,\n\toptions?: OutputOptions,\n): string {\n\tconst { useHash, usePostfix } = getOutputOptions(options);\n\tlet name = \"[name]\";\n\tif (useHash) {\n\t\tname += \".[contenthash]\";\n\t}\n\tif (usePostfix && postfix) {\n\t\tname += \".\" + postfix;\n\t}\n\treturn name + \".\" + extension;\n}\n\n/**\n * Get the webpack configuration.\n *\n * @param entry The entry object to use.\n * @param options The options for the configuration.\n * @returns The webpack configuration.\n */\nexport function getWebpackConfig(\n\tentry?: EntryObject,\n\toptions?: GetConfigOptions,\n): WebpackConfiguration {\n\tconst {\n\t\tadditionalExtensions = [],\n\t\taliases,\n\t\tdevtool = \"source-map\",\n\t\toutputPath = path.resolve(\"dist\"),\n\t} = options ?? {};\n\tconst extensions: string[] = [\n\t\t\".tsx\",\n\t\t\".ts\",\n\t\t\".js\",\n\t\t\".css\",\n\t\t\".scss\",\n\t\t...additionalExtensions,\n\t];\n\tconst resolve: NonNullable<WebpackConfiguration[\"resolve\"]> = {\n\t\textensionAlias: {\n\t\t\t\".js\": [\".js\", \".ts\", \".tsx\"],\n\t\t},\n\t\textensions,\n\t};\n\tif (aliases) {\n\t\tresolve.alias = aliases;\n\t}\n\n\tconst baseConfig: WebpackConfiguration = {\n\t\tdevtool,\n\t\tmodule: {\n\t\t\trules: getRules(options),\n\t\t},\n\t\toutput: {\n\t\t\tchunkFilename: getOutputName(\"chunk\", \"js\", options),\n\t\t\tfilename: getOutputName(\"bundle\", \"js\", options),\n\t\t\tpath: outputPath,\n\t\t},\n\t\tplugins: getPlugins(options),\n\t\tresolve,\n\t};\n\tconst optimization = getOptimizationOptions(options);\n\tif (optimization) {\n\t\tbaseConfig.optimization = optimization;\n\t}\n\tif (entry) {\n\t\tbaseConfig.entry = entry;\n\t}\n\treturn baseConfig;\n}\n\n/**\n * Get the options pertaining to optimization.\n *\n * @param options The output options.\n * @returns The optimization settings.\n */\nfunction getOptimizationOptions(\n\toptions?: OutputOptions,\n): WebpackConfiguration[\"optimization\"] {\n\tconst { optimize } = getOutputOptions(options);\n\treturn optimize\n\t\t? {\n\t\t\t\tminimizer: [`...`, new CssMinimizerPlugin()],\n\t\t\t\tsideEffects: true,\n\t\t\t\tsplitChunks: {\n\t\t\t\t\tautomaticNameDelimiter: \"~\",\n\t\t\t\t\tcacheGroups: {\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tminChunks: 2,\n\t\t\t\t\t\t\tpriority: -20,\n\t\t\t\t\t\t\treuseExistingChunk: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefaultVendors: {\n\t\t\t\t\t\t\tpriority: -10,\n\t\t\t\t\t\t\ttest: /[\\\\/]node_modules[\\\\/]/,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tenforceSizeThreshold: 50000,\n\t\t\t\t\tmaxAsyncRequests: 30,\n\t\t\t\t\tmaxInitialRequests: 30,\n\t\t\t\t\tminChunks: 1,\n\t\t\t\t\tminSize: 20000,\n\t\t\t\t},\n\t\t\t\tusedExports: true,\n\t\t\t}\n\t\t: undefined;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { EntryObject, Configuration as WebpackConfiguration } from "webpack";
2
+ /**
3
+ * Gets a configuration for bundling from a CSS entrypoint.
4
+ *
5
+ * @param entry The entrypoint for the CSS.
6
+ * @returns The webpack configuration.
7
+ */
8
+ export declare function getCssConfig(entry: EntryObject): WebpackConfiguration;
9
+ //# sourceMappingURL=cssConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssConfig.d.ts","sourceRoot":"","sources":["../../src/cssConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,aAAa,IAAI,oBAAoB,EACrC,MAAM,SAAS,CAAC;AAIjB;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,oBAAoB,CAErE"}
@@ -0,0 +1,11 @@
1
+ import { getWebpackConfig } from "./base.js";
2
+ /**
3
+ * Gets a configuration for bundling from a CSS entrypoint.
4
+ *
5
+ * @param entry The entrypoint for the CSS.
6
+ * @returns The webpack configuration.
7
+ */
8
+ export function getCssConfig(entry) {
9
+ return getWebpackConfig(entry, { useHash: false, usePostfix: false });
10
+ }
11
+ //# sourceMappingURL=cssConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssConfig.js","sourceRoot":"","sources":["../../src/cssConfig.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC9C,OAAO,gBAAgB,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type {\n\tEntryObject,\n\tConfiguration as WebpackConfiguration,\n} from \"webpack\";\n\nimport { getWebpackConfig } from \"./base.js\";\n\n/**\n * Gets a configuration for bundling from a CSS entrypoint.\n *\n * @param entry The entrypoint for the CSS.\n * @returns The webpack configuration.\n */\nexport function getCssConfig(entry: EntryObject): WebpackConfiguration {\n\treturn getWebpackConfig(entry, { useHash: false, usePostfix: false });\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { EntryObject } from "webpack";
2
+ import type { WebpackConfiguration } from "webpack-dev-server";
3
+ import type { GetConfigOptions } from "./types.js";
4
+ export type DevConfigOptions = GetConfigOptions & {
5
+ additionalEntrypoints?: EntryObject;
6
+ port?: NonNullable<WebpackConfiguration["devServer"]>["port"];
7
+ };
8
+ /**
9
+ * Get the webpack configuration.
10
+ *
11
+ * @param jsEntry The JS entry point for the development server.
12
+ * @param htmlTemplate The HTML template to use. This will be a page that
13
+ * utilizes the JS entry point.
14
+ * @param options Additional options for customizing the configuration.
15
+ * @returns The webpack configuration.
16
+ */
17
+ export declare function getWebpackDevConfig(jsEntry: string, htmlTemplate: string, options?: DevConfigOptions): WebpackConfiguration;
18
+ //# sourceMappingURL=devConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devConfig.d.ts","sourceRoot":"","sources":["../../src/devConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IACjD,qBAAqB,CAAC,EAAE,WAAW,CAAC;IACpC,IAAI,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CAC9D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,gBAAgB,GACxB,oBAAoB,CA4BtB"}
@@ -0,0 +1,38 @@
1
+ import * as path from "path";
2
+ import HtmlWebpackPlugin from "html-webpack-plugin";
3
+ import { getWebpackConfig } from "./base.js";
4
+ /**
5
+ * Get the webpack configuration.
6
+ *
7
+ * @param jsEntry The JS entry point for the development server.
8
+ * @param htmlTemplate The HTML template to use. This will be a page that
9
+ * utilizes the JS entry point.
10
+ * @param options Additional options for customizing the configuration.
11
+ * @returns The webpack configuration.
12
+ */
13
+ export function getWebpackDevConfig(jsEntry, htmlTemplate, options) {
14
+ const { additionalEntrypoints, port, ...rest } = options ?? {};
15
+ const config = getWebpackConfig({
16
+ index: jsEntry,
17
+ ...(additionalEntrypoints ?? {}),
18
+ }, {
19
+ additionalPlugins: [
20
+ new HtmlWebpackPlugin({
21
+ template: htmlTemplate,
22
+ }),
23
+ ],
24
+ devtool: "inline-source-map",
25
+ optimize: false,
26
+ useHash: false,
27
+ usePostfix: false,
28
+ ...rest,
29
+ });
30
+ config.devServer = {
31
+ hot: true,
32
+ port: port ?? 8080,
33
+ static: path.resolve("dist"),
34
+ };
35
+ config.mode = "development";
36
+ return config;
37
+ }
38
+ //# sourceMappingURL=devConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devConfig.js","sourceRoot":"","sources":["../../src/devConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAIpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAQ7C;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAClC,OAAe,EACf,YAAoB,EACpB,OAA0B;IAE1B,MAAM,EAAE,qBAAqB,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC/D,MAAM,MAAM,GAAG,gBAAgB,CAC9B;QACC,KAAK,EAAE,OAAO;QACd,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;KAChC,EACD;QACC,iBAAiB,EAAE;YAClB,IAAI,iBAAiB,CAAC;gBACrB,QAAQ,EAAE,YAAY;aACtB,CAAC;SACF;QACD,OAAO,EAAE,mBAAmB;QAC5B,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,KAAK;QACjB,GAAG,IAAI;KACP,CACD,CAAC;IACF,MAAM,CAAC,SAAS,GAAG;QAClB,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,IAAI,IAAI,IAAI;QAClB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;KAC5B,CAAC;IAEF,MAAM,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import * as path from \"path\";\nimport HtmlWebpackPlugin from \"html-webpack-plugin\";\nimport type { EntryObject } from \"webpack\";\nimport type { WebpackConfiguration } from \"webpack-dev-server\";\n\nimport { getWebpackConfig } from \"./base.js\";\nimport type { GetConfigOptions } from \"./types.js\";\n\nexport type DevConfigOptions = GetConfigOptions & {\n\tadditionalEntrypoints?: EntryObject;\n\tport?: NonNullable<WebpackConfiguration[\"devServer\"]>[\"port\"];\n};\n\n/**\n * Get the webpack configuration.\n *\n * @param jsEntry The JS entry point for the development server.\n * @param htmlTemplate The HTML template to use. This will be a page that\n * utilizes the JS entry point.\n * @param options Additional options for customizing the configuration.\n * @returns The webpack configuration.\n */\nexport function getWebpackDevConfig(\n\tjsEntry: string,\n\thtmlTemplate: string,\n\toptions?: DevConfigOptions,\n): WebpackConfiguration {\n\tconst { additionalEntrypoints, port, ...rest } = options ?? {};\n\tconst config = getWebpackConfig(\n\t\t{\n\t\t\tindex: jsEntry,\n\t\t\t...(additionalEntrypoints ?? {}),\n\t\t},\n\t\t{\n\t\t\tadditionalPlugins: [\n\t\t\t\tnew HtmlWebpackPlugin({\n\t\t\t\t\ttemplate: htmlTemplate,\n\t\t\t\t}),\n\t\t\t],\n\t\t\tdevtool: \"inline-source-map\",\n\t\t\toptimize: false,\n\t\t\tuseHash: false,\n\t\t\tusePostfix: false,\n\t\t\t...rest,\n\t\t},\n\t);\n\tconfig.devServer = {\n\t\thot: true,\n\t\tport: port ?? 8080,\n\t\tstatic: path.resolve(\"dist\"),\n\t};\n\n\tconfig.mode = \"development\";\n\treturn config;\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { WebpackPluginInstance } from "webpack";
2
+ import type { GetPluginsOptions } from "./types.js";
3
+ /**
4
+ * Gets the plugins for the configuration
5
+ *
6
+ * @param options The options to use for generating the plugin configuration.
7
+ * @returns The plugins to use.
8
+ */
9
+ export declare function getPlugins(options?: GetPluginsOptions): WebpackPluginInstance[];
10
+ //# sourceMappingURL=getPlugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPlugins.d.ts","sourceRoot":"","sources":["../../src/getPlugins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAMrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,OAAO,CAAC,EAAE,iBAAiB,GACzB,qBAAqB,EAAE,CAkBzB"}
@@ -0,0 +1,30 @@
1
+ import MiniCssExtractPlugin from "mini-css-extract-plugin";
2
+ import { WebpackManifestPlugin } from "webpack-manifest-plugin";
3
+ import RemoveEmptyScriptsPlugin from "webpack-remove-empty-scripts";
4
+ import { getOutputName } from "./base.js";
5
+ import { getOutputOptions } from "./outputOptions.js";
6
+ /**
7
+ * Gets the plugins for the configuration
8
+ *
9
+ * @param options The options to use for generating the plugin configuration.
10
+ * @returns The plugins to use.
11
+ */
12
+ export function getPlugins(options) {
13
+ const { useHash } = getOutputOptions(options);
14
+ const plugins = [
15
+ new MiniCssExtractPlugin({
16
+ chunkFilename: getOutputName("chunk", "css", options),
17
+ filename: getOutputName("", "css", options),
18
+ }),
19
+ new RemoveEmptyScriptsPlugin(),
20
+ ];
21
+ if (useHash)
22
+ plugins.push(new WebpackManifestPlugin({
23
+ fileName: "manifest.json",
24
+ filter: (file) => file.isInitial,
25
+ }));
26
+ if (options?.additionalPlugins)
27
+ plugins.push(...options.additionalPlugins);
28
+ return plugins;
29
+ }
30
+ //# sourceMappingURL=getPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPlugins.js","sourceRoot":"","sources":["../../src/getPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,wBAAwB,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACzB,OAA2B;IAE3B,MAAM,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,OAAO,GAA4B;QACxC,IAAI,oBAAoB,CAAC;YACxB,aAAa,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;YACrD,QAAQ,EAAE,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC;SAC3C,CAAC;QACF,IAAI,wBAAwB,EAAE;KAC9B,CAAC;IACF,IAAI,OAAO;QACV,OAAO,CAAC,IAAI,CACX,IAAI,qBAAqB,CAAC;YACzB,QAAQ,EAAE,eAAe;YACzB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS;SAChC,CAAC,CACF,CAAC;IACH,IAAI,OAAO,EAAE,iBAAiB;QAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3E,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import MiniCssExtractPlugin from \"mini-css-extract-plugin\";\nimport type { WebpackPluginInstance } from \"webpack\";\nimport { WebpackManifestPlugin } from \"webpack-manifest-plugin\";\nimport RemoveEmptyScriptsPlugin from \"webpack-remove-empty-scripts\";\n\nimport { getOutputName } from \"./base.js\";\nimport { getOutputOptions } from \"./outputOptions.js\";\nimport type { GetPluginsOptions } from \"./types.js\";\n\n/**\n * Gets the plugins for the configuration\n *\n * @param options The options to use for generating the plugin configuration.\n * @returns The plugins to use.\n */\nexport function getPlugins(\n\toptions?: GetPluginsOptions,\n): WebpackPluginInstance[] {\n\tconst { useHash } = getOutputOptions(options);\n\tconst plugins: WebpackPluginInstance[] = [\n\t\tnew MiniCssExtractPlugin({\n\t\t\tchunkFilename: getOutputName(\"chunk\", \"css\", options),\n\t\t\tfilename: getOutputName(\"\", \"css\", options),\n\t\t}),\n\t\tnew RemoveEmptyScriptsPlugin(),\n\t];\n\tif (useHash)\n\t\tplugins.push(\n\t\t\tnew WebpackManifestPlugin({\n\t\t\t\tfileName: \"manifest.json\",\n\t\t\t\tfilter: (file) => file.isInitial,\n\t\t\t}),\n\t\t);\n\tif (options?.additionalPlugins) plugins.push(...options.additionalPlugins);\n\treturn plugins;\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { RuleSetRule } from "webpack";
2
+ import type { GetRulesOptions } from "./types.js";
3
+ /**
4
+ * Gets the rules for the configuration.
5
+ *
6
+ * @param options The options for the resolution rules.
7
+ * @returns The resolution rules.
8
+ */
9
+ export declare function getRules(options?: GetRulesOptions): RuleSetRule[];
10
+ //# sourceMappingURL=getRules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRules.d.ts","sourceRoot":"","sources":["../../src/getRules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkFlD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,WAAW,EAAE,CAUjE"}
@@ -0,0 +1,103 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import path from "path";
5
+ import MiniCssExtractPlugin from "mini-css-extract-plugin";
6
+ import { protectSupportsPlugin, restoreSupportsPlugin, } from "./postcssProtectSupports.js";
7
+ const require = createRequire(import.meta.url);
8
+ /* v8 ignore next 8 */
9
+ let dir;
10
+ try {
11
+ dir = __dirname;
12
+ // eslint-disable-next-line sonarjs/no-ignored-exceptions
13
+ }
14
+ catch (_e) {
15
+ // eslint-disable-next-line
16
+ // @ts-ignore
17
+ dir = dirname(fileURLToPath(import.meta.url));
18
+ }
19
+ const postcssLoader = {
20
+ loader: require.resolve("postcss-loader"),
21
+ options: {
22
+ postcssOptions: {
23
+ plugins: [
24
+ "@tailwindcss/postcss",
25
+ protectSupportsPlugin(),
26
+ [
27
+ "postcss-preset-env",
28
+ {
29
+ autoprefixer: true,
30
+ browsers: "> 1% in CA, not dead",
31
+ },
32
+ ],
33
+ restoreSupportsPlugin(),
34
+ ],
35
+ },
36
+ },
37
+ };
38
+ const baseRules = [
39
+ {
40
+ exclude: /node_modules/,
41
+ test: /\.tsx?$/,
42
+ use: require.resolve("ts-loader"),
43
+ },
44
+ {
45
+ resolve: {
46
+ fullySpecified: false,
47
+ },
48
+ test: /\.m?js/,
49
+ },
50
+ {
51
+ exclude: /\.module\.s?css$/,
52
+ test: /\.s?css$/,
53
+ use: [
54
+ MiniCssExtractPlugin.loader,
55
+ require.resolve("css-loader"),
56
+ postcssLoader,
57
+ path.resolve(dir, "prefixPatcher.js"),
58
+ require.resolve("sass-loader"),
59
+ ],
60
+ },
61
+ {
62
+ include: /\.module\.s?css$/,
63
+ test: /\.s?css$/,
64
+ use: [
65
+ MiniCssExtractPlugin.loader,
66
+ {
67
+ loader: require.resolve("css-loader"),
68
+ options: {
69
+ modules: {
70
+ localIdentName: "[name]__[local]--[hash:base64:5]",
71
+ },
72
+ },
73
+ },
74
+ postcssLoader,
75
+ require.resolve("sass-loader"),
76
+ ],
77
+ },
78
+ {
79
+ generator: {
80
+ filename: "assets/[name].[hash][ext]",
81
+ },
82
+ test: /\.(png|jpe?g|gif|svg|webp)$/i,
83
+ type: "asset/resource",
84
+ },
85
+ ];
86
+ /**
87
+ * Gets the rules for the configuration.
88
+ *
89
+ * @param options The options for the resolution rules.
90
+ * @returns The resolution rules.
91
+ */
92
+ export function getRules(options) {
93
+ const { additionalRules = [], excludedRules = [] } = options ?? {};
94
+ const rules = [];
95
+ for (const baseRule of baseRules) {
96
+ const { test } = baseRule;
97
+ if (!excludedRules.some((rule) => test.toString() === rule.toString())) {
98
+ rules.push(baseRule);
99
+ }
100
+ }
101
+ return rules.concat(additionalRules);
102
+ }
103
+ //# sourceMappingURL=getRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRules.js","sourceRoot":"","sources":["../../src/getRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EACN,qBAAqB,EACrB,qBAAqB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,sBAAsB;AACtB,IAAI,GAAG,CAAC;AACR,IAAI,CAAC;IACJ,GAAG,GAAG,SAAS,CAAC;IAChB,yDAAyD;AAC1D,CAAC;AAAC,OAAO,EAAE,EAAE,CAAC;IACb,2BAA2B;IAC3B,aAAa;IACb,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AACD,MAAM,aAAa,GAAG;IACrB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACzC,OAAO,EAAE;QACR,cAAc,EAAE;YAC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AAO,IAAI,EAAE,CAAC;IACnE,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;YACxE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport path from \"path\";\nimport MiniCssExtractPlugin from \"mini-css-extract-plugin\";\nimport type { RuleSetRule } from \"webpack\";\n\nimport {\n\tprotectSupportsPlugin,\n\trestoreSupportsPlugin,\n} from \"./postcssProtectSupports.js\";\nimport type { GetRulesOptions } from \"./types.js\";\n\nconst require = createRequire(import.meta.url);\n/* v8 ignore next 8 */\nlet dir;\ntry {\n\tdir = __dirname;\n\t// eslint-disable-next-line sonarjs/no-ignored-exceptions\n} catch (_e) {\n\t// eslint-disable-next-line\n\t// @ts-ignore\n\tdir = dirname(fileURLToPath(import.meta.url));\n}\nconst postcssLoader = {\n\tloader: require.resolve(\"postcss-loader\"),\n\toptions: {\n\t\tpostcssOptions: {\n\t\t\tplugins: [\n\t\t\t\t\"@tailwindcss/postcss\",\n\t\t\t\tprotectSupportsPlugin(),\n\t\t\t\t[\n\t\t\t\t\t\"postcss-preset-env\",\n\t\t\t\t\t{\n\t\t\t\t\t\tautoprefixer: true,\n\t\t\t\t\t\tbrowsers: \"> 1% in CA, not dead\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\trestoreSupportsPlugin(),\n\t\t\t],\n\t\t},\n\t},\n};\n\nconst baseRules: (RuleSetRule & { test: RegExp })[] = [\n\t{\n\t\texclude: /node_modules/,\n\t\ttest: /\\.tsx?$/,\n\t\tuse: require.resolve(\"ts-loader\"),\n\t},\n\t{\n\t\tresolve: {\n\t\t\tfullySpecified: false,\n\t\t},\n\t\ttest: /\\.m?js/,\n\t},\n\t{\n\t\texclude: /\\.module\\.s?css$/,\n\t\ttest: /\\.s?css$/,\n\t\tuse: [\n\t\t\tMiniCssExtractPlugin.loader,\n\t\t\trequire.resolve(\"css-loader\"),\n\t\t\tpostcssLoader,\n\t\t\tpath.resolve(dir, \"prefixPatcher.js\"),\n\t\t\trequire.resolve(\"sass-loader\"),\n\t\t],\n\t},\n\t{\n\t\tinclude: /\\.module\\.s?css$/,\n\t\ttest: /\\.s?css$/,\n\t\tuse: [\n\t\t\tMiniCssExtractPlugin.loader,\n\t\t\t{\n\t\t\t\tloader: require.resolve(\"css-loader\"),\n\t\t\t\toptions: {\n\t\t\t\t\tmodules: {\n\t\t\t\t\t\tlocalIdentName: \"[name]__[local]--[hash:base64:5]\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tpostcssLoader,\n\t\t\trequire.resolve(\"sass-loader\"),\n\t\t],\n\t},\n\t{\n\t\tgenerator: {\n\t\t\tfilename: \"assets/[name].[hash][ext]\",\n\t\t},\n\t\ttest: /\\.(png|jpe?g|gif|svg|webp)$/i,\n\t\ttype: \"asset/resource\",\n\t},\n];\n\n/**\n * Gets the rules for the configuration.\n *\n * @param options The options for the resolution rules.\n * @returns The resolution rules.\n */\nexport function getRules(options?: GetRulesOptions): RuleSetRule[] {\n\tconst { additionalRules = [], excludedRules = [] } = options ?? {};\n\tconst rules: RuleSetRule[] = [];\n\tfor (const baseRule of baseRules) {\n\t\tconst { test } = baseRule;\n\t\tif (!excludedRules.some((rule) => test.toString() === rule.toString())) {\n\t\t\trules.push(baseRule);\n\t\t}\n\t}\n\treturn rules.concat(additionalRules);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export * from "./base.js";
2
+ export * from "./cssConfig.js";
3
+ export * from "./devConfig.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./base.js";
2
+ export * from "./cssConfig.js";
3
+ export * from "./devConfig.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./base.js\";\nexport * from \"./cssConfig.js\";\nexport * from \"./devConfig.js\";\n"]}
@@ -0,0 +1,10 @@
1
+ import type { OutputOptions } from "./types.js";
2
+ /**
3
+ * Creates an object with the required output options. Filling from defaults
4
+ * where required.
5
+ *
6
+ * @param supplied The consumer-supplied options.
7
+ * @returns The options, defaulted where necessary.
8
+ */
9
+ export declare function getOutputOptions(supplied?: OutputOptions): Required<OutputOptions>;
10
+ //# sourceMappingURL=outputOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputOptions.d.ts","sourceRoot":"","sources":["../../src/outputOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAQhD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,QAAQ,CAAC,EAAE,aAAa,GACtB,QAAQ,CAAC,aAAa,CAAC,CAEzB"}
@@ -0,0 +1,16 @@
1
+ const defaultOutputOptions = Object.freeze({
2
+ optimize: true,
3
+ useHash: true,
4
+ usePostfix: true,
5
+ });
6
+ /**
7
+ * Creates an object with the required output options. Filling from defaults
8
+ * where required.
9
+ *
10
+ * @param supplied The consumer-supplied options.
11
+ * @returns The options, defaulted where necessary.
12
+ */
13
+ export function getOutputOptions(supplied) {
14
+ return Object.assign({}, defaultOutputOptions, supplied);
15
+ }
16
+ //# sourceMappingURL=outputOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputOptions.js","sourceRoot":"","sources":["../../src/outputOptions.ts"],"names":[],"mappings":"AAEA,MAAM,oBAAoB,GAAsC,MAAM,CAAC,MAAM,CAAC;IAC7E,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC/B,QAAwB;IAExB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,oBAAoB,EAAE,QAAQ,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import type { OutputOptions } from \"./types.js\";\n\nconst defaultOutputOptions: Readonly<Required<OutputOptions>> = Object.freeze({\n\toptimize: true,\n\tuseHash: true,\n\tusePostfix: true,\n});\n\n/**\n * Creates an object with the required output options. Filling from defaults\n * where required.\n *\n * @param supplied The consumer-supplied options.\n * @returns The options, defaulted where necessary.\n */\nexport function getOutputOptions(\n\tsupplied?: OutputOptions,\n): Required<OutputOptions> {\n\treturn Object.assign({}, defaultOutputOptions, supplied);\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { Plugin } from "postcss";
2
+ /**
3
+ * PostCSS plugin that protects logical CSS properties inside `@supports` blocks
4
+ * by prefixing them with a temporary marker, preventing downstream
5
+ * transpilation.
6
+ *
7
+ * @returns A PostCSS plugin object that protects logical CSS properties within
8
+ * an `@supports` block.
9
+ */
10
+ export declare function protectSupportsPlugin(): Plugin;
11
+ export declare namespace protectSupportsPlugin {
12
+ var postcss: boolean;
13
+ }
14
+ /**
15
+ * PostCSS plugin that restores the original property names of protected CSS
16
+ * properties.
17
+ *
18
+ * @returns A PostCSS plugin object that restores the original property names of
19
+ * the rules within an `@supports` block.
20
+ */
21
+ export declare function restoreSupportsPlugin(): Plugin;
22
+ export declare namespace restoreSupportsPlugin {
23
+ var postcss: boolean;
24
+ }
25
+ //# sourceMappingURL=postcssProtectSupports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcssProtectSupports.d.ts","sourceRoot":"","sources":["../../src/postcssProtectSupports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,MAAM,EAAQ,MAAM,SAAS,CAAC;AAIzD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAW9C;;;;AAsBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAW9C"}
@@ -0,0 +1,59 @@
1
+ const MARKER = "__skip_logical__";
2
+ /**
3
+ * PostCSS plugin that protects logical CSS properties inside `@supports` blocks
4
+ * by prefixing them with a temporary marker, preventing downstream
5
+ * transpilation.
6
+ *
7
+ * @returns A PostCSS plugin object that protects logical CSS properties within
8
+ * an `@supports` block.
9
+ */
10
+ export function protectSupportsPlugin() {
11
+ return {
12
+ Once(root) {
13
+ root.walkDecls((decl) => {
14
+ if (!decl.prop.startsWith(MARKER) && isInsideSupports(decl)) {
15
+ decl.prop = `${MARKER}${decl.prop}`;
16
+ }
17
+ });
18
+ },
19
+ postcssPlugin: "postcss-protect-supports",
20
+ };
21
+ }
22
+ /**
23
+ * Checks if a PostCSS node is nested within a `@supports` at-rule.
24
+ *
25
+ * @param node The PostCSS node to verify.
26
+ * @returns True if the node is inside a `@supports` rule, false otherwise.
27
+ */
28
+ function isInsideSupports(node) {
29
+ let parent = node.parent;
30
+ while (parent) {
31
+ if (parent.type === "atrule" && parent.name === "supports") {
32
+ return true;
33
+ }
34
+ parent = parent.parent;
35
+ }
36
+ return false;
37
+ }
38
+ protectSupportsPlugin.postcss = true;
39
+ /**
40
+ * PostCSS plugin that restores the original property names of protected CSS
41
+ * properties.
42
+ *
43
+ * @returns A PostCSS plugin object that restores the original property names of
44
+ * the rules within an `@supports` block.
45
+ */
46
+ export function restoreSupportsPlugin() {
47
+ return {
48
+ OnceExit(root) {
49
+ root.walkDecls((decl) => {
50
+ if (decl.prop.startsWith(MARKER)) {
51
+ decl.prop = decl.prop.slice(MARKER.length);
52
+ }
53
+ });
54
+ },
55
+ postcssPlugin: "postcss-restore-supports",
56
+ };
57
+ }
58
+ restoreSupportsPlugin.postcss = true;
59
+ //# sourceMappingURL=postcssProtectSupports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcssProtectSupports.js","sourceRoot":"","sources":["../../src/postcssProtectSupports.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB;IACpC,OAAO;QACN,IAAI,CAAC,IAAU;YACd,IAAI,CAAC,SAAS,CAAC,CAAC,IAAiB,EAAE,EAAE;gBACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC7D,IAAI,CAAC,IAAI,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;gBACrC,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,aAAa,EAAE,0BAA0B;KACzC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,IAAiB;IAC1C,IAAI,MAAM,GAEwC,IAAI,CAAC,MAAM,CAAC;IAC9D,OAAO,MAAM,EAAE,CAAC;QACf,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC;QACb,CAAC;QACD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AACD,qBAAqB,CAAC,OAAO,GAAG,IAAI,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACpC,OAAO;QACN,QAAQ,CAAC,IAAU;YAClB,IAAI,CAAC,SAAS,CAAC,CAAC,IAAiB,EAAE,EAAE;gBACpC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;oBAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC5C,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,aAAa,EAAE,0BAA0B;KACzC,CAAC;AACH,CAAC;AACD,qBAAqB,CAAC,OAAO,GAAG,IAAI,CAAC","sourcesContent":["import type { Declaration, Plugin, Root } from \"postcss\";\n\nconst MARKER = \"__skip_logical__\";\n\n/**\n * PostCSS plugin that protects logical CSS properties inside `@supports` blocks\n * by prefixing them with a temporary marker, preventing downstream\n * transpilation.\n *\n * @returns A PostCSS plugin object that protects logical CSS properties within\n * an `@supports` block.\n */\nexport function protectSupportsPlugin(): Plugin {\n\treturn {\n\t\tOnce(root: Root) {\n\t\t\troot.walkDecls((decl: Declaration) => {\n\t\t\t\tif (!decl.prop.startsWith(MARKER) && isInsideSupports(decl)) {\n\t\t\t\t\tdecl.prop = `${MARKER}${decl.prop}`;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tpostcssPlugin: \"postcss-protect-supports\",\n\t};\n}\n\n/**\n * Checks if a PostCSS node is nested within a `@supports` at-rule.\n *\n * @param node The PostCSS node to verify.\n * @returns True if the node is inside a `@supports` rule, false otherwise.\n */\nfunction isInsideSupports(node: Declaration): boolean {\n\tlet parent:\n\t\t| Declaration[\"parent\"]\n\t\t| NonNullable<Declaration[\"parent\"]>[\"parent\"] = node.parent;\n\twhile (parent) {\n\t\tif (parent.type === \"atrule\" && parent.name === \"supports\") {\n\t\t\treturn true;\n\t\t}\n\t\tparent = parent.parent;\n\t}\n\treturn false;\n}\nprotectSupportsPlugin.postcss = true;\n\n/**\n * PostCSS plugin that restores the original property names of protected CSS\n * properties.\n *\n * @returns A PostCSS plugin object that restores the original property names of\n * the rules within an `@supports` block.\n */\nexport function restoreSupportsPlugin(): Plugin {\n\treturn {\n\t\tOnceExit(root: Root) {\n\t\t\troot.walkDecls((decl: Declaration) => {\n\t\t\t\tif (decl.prop.startsWith(MARKER)) {\n\t\t\t\t\tdecl.prop = decl.prop.slice(MARKER.length);\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tpostcssPlugin: \"postcss-restore-supports\",\n\t};\n}\nrestoreSupportsPlugin.postcss = true;\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Fixes an issue where the sass-loader removes the space between the tailwind
3
+ * import and a prefix.
4
+ *
5
+ * @param source The source code
6
+ * @returns The adjusted source.
7
+ */
8
+ export default function (source: any): any;
9
+ //# sourceMappingURL=prefixPatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefixPatcher.d.ts","sourceRoot":"","sources":["../../src/prefixPatcher.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,WAAW,MAAM,KAAA,OAE9B"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Fixes an issue where the sass-loader removes the space between the tailwind
3
+ * import and a prefix.
4
+ *
5
+ * @param source The source code
6
+ * @returns The adjusted source.
7
+ */
8
+ export default function (source) {
9
+ return source.replace(/(\S)(prefix\(\w+\))/g, "$1 $2");
10
+ }
11
+ //# sourceMappingURL=prefixPatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefixPatcher.js","sourceRoot":"","sources":["../../src/prefixPatcher.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,WAAW,MAAM;IAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/**\n * Fixes an issue where the sass-loader removes the space between the tailwind\n * import and a prefix.\n *\n * @param source The source code\n * @returns The adjusted source.\n */\nexport default function (source) {\n\treturn source.replace(/(\\S)(prefix\\(\\w+\\))/g, \"$1 $2\");\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { RuleSetRule, Configuration as WebpackConfiguration, WebpackPluginInstance } from "webpack";
2
+ export type GetConfigOptions = GetPluginsOptions & GetRulesOptions & {
3
+ additionalExtensions?: string[];
4
+ aliases?: Record<string, string>;
5
+ devtool?: WebpackConfiguration["devtool"];
6
+ outputPath?: string;
7
+ };
8
+ export type GetPluginsOptions = OutputOptions & {
9
+ additionalPlugins?: WebpackPluginInstance[];
10
+ };
11
+ export type GetRulesOptions = {
12
+ additionalRules?: RuleSetRule[];
13
+ excludedRules?: RegExp[];
14
+ };
15
+ export type OutputOptions = {
16
+ optimize?: boolean;
17
+ useHash?: boolean;
18
+ usePostfix?: boolean;
19
+ };
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,aAAa,IAAI,oBAAoB,EACrC,qBAAqB,EACrB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAC/C,eAAe,GAAG;IACjB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC/C,iBAAiB,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,eAAe,CAAC,EAAE,WAAW,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tRuleSetRule,\n\tConfiguration as WebpackConfiguration,\n\tWebpackPluginInstance,\n} from \"webpack\";\n\nexport type GetConfigOptions = GetPluginsOptions &\n\tGetRulesOptions & {\n\t\tadditionalExtensions?: string[];\n\t\taliases?: Record<string, string>;\n\t\tdevtool?: WebpackConfiguration[\"devtool\"];\n\t\toutputPath?: string;\n\t};\n\nexport type GetPluginsOptions = OutputOptions & {\n\tadditionalPlugins?: WebpackPluginInstance[];\n};\n\nexport type GetRulesOptions = {\n\tadditionalRules?: RuleSetRule[];\n\texcludedRules?: RegExp[];\n};\n\nexport type OutputOptions = {\n\toptimize?: boolean;\n\tuseHash?: boolean;\n\tusePostfix?: boolean;\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@rootreeweb/rt-webpack-helper",
3
+ "version": "4.1.1",
4
+ "description": "JavaScript package for generating a standardized WebPack configuration for projects",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/rootreeweb/meta-tools.git"
8
+ },
9
+ "author": {
10
+ "name": "Rootree Web",
11
+ "email": "web@rootree.ca"
12
+ },
13
+ "sideEffects": false,
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./dist/esm/index.d.ts",
19
+ "default": "./dist/esm/index.js"
20
+ }
21
+ }
22
+ },
23
+ "types": "./dist/esm/index.d.ts",
24
+ "files": [
25
+ "dist/**/*"
26
+ ],
27
+ "scripts": {
28
+ "build": "yarn run clean && yarn run build:esm",
29
+ "build:esm": "tsgo -p ./configs/tsconfig.esm.json",
30
+ "check": "tsgo --noEmit",
31
+ "clean": "del-cli ./dist",
32
+ "format": "prettier . --cache --write",
33
+ "lint": "eslint --fix --cache",
34
+ "prepare": "husky",
35
+ "release": "yarn dlx -p @rootreeweb/rt-node-lib release ${0}",
36
+ "test": "vitest run --coverage",
37
+ "test:watch": "vitest --coverage --ui"
38
+ },
39
+ "dependencies": {
40
+ "@tailwindcss/postcss": "4.3.0",
41
+ "css-loader": "7.1.4",
42
+ "css-minimizer-webpack-plugin": "8.0.0",
43
+ "cssnano": "8.0.1",
44
+ "html-webpack-plugin": "5.6.7",
45
+ "mini-css-extract-plugin": "2.10.2",
46
+ "postcss": "8.5.15",
47
+ "postcss-loader": "8.2.1",
48
+ "postcss-media-minmax": "5.0.0",
49
+ "postcss-preset-env": "11.3.0",
50
+ "sass": "1.100.0",
51
+ "sass-loader": "17.0.0",
52
+ "tailwindcss": "^4.3.0",
53
+ "ts-loader": "9.5.7",
54
+ "webpack-dev-server": "^5.2.4",
55
+ "webpack-manifest-plugin": "6.0.1",
56
+ "webpack-remove-empty-scripts": "1.1.1"
57
+ },
58
+ "devDependencies": {
59
+ "@rootreeweb/fonts": "^1.0.37",
60
+ "@rootreeweb/linting": "4.2.1",
61
+ "@rootreeweb/rt-node-lib": "8.1.26",
62
+ "@rootreeweb/tsconfigs": "3.3.8",
63
+ "@types/node": "^25.9.1",
64
+ "@types/webpack-dev-server": "^4.7.2",
65
+ "@typescript/native-preview": "^7.0.0-dev.20260522.1",
66
+ "@vitest/coverage-v8": "^4.1.7",
67
+ "@vitest/ui": "^4.1.7",
68
+ "del-cli": "^7.0.0",
69
+ "eslint": "^10.4.0",
70
+ "husky": "^9.1.7",
71
+ "knip": "^6.14.2",
72
+ "lint-staged": "^17.0.5",
73
+ "memfs": "^4.57.2",
74
+ "prettier": "^3.8.3",
75
+ "stylelint": "^17.12.0",
76
+ "typescript": "^6.0.3",
77
+ "vitest": "^4.1.7",
78
+ "webpack": "^5.107.1",
79
+ "webpack-cli": "^7.0.2"
80
+ },
81
+ "peerDependencies": {
82
+ "webpack": "^5",
83
+ "webpack-cli": "^7"
84
+ }
85
+ }