@enhanced-dom/webpack 0.0.7 → 0.0.8
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/configs/index.js +1 -0
- package/configs/index.js.map +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -0
- package/loaders/ExposeCssSourceLoader.js +4 -2
- package/loaders/ExposeCssSourceLoader.js.map +1 -0
- package/loaders/index.js +1 -0
- package/loaders/index.js.map +1 -0
- package/package.json +2 -1
- package/plugins/HtmlWebpackInlineSourcePlugin.js +1 -0
- package/plugins/HtmlWebpackInlineSourcePlugin.js.map +1 -0
- package/plugins/index.js +1 -0
- package/plugins/index.js.map +1 -0
package/configs/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["configs/index.ts"],"names":[],"mappings":";;;;;;AAAA,4FAAgE;AAEhE,wCAA+C;AAExC,MAAM,wBAAwB,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,EAA2C,EAAE,EAAE;IACvG,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;QAC7B,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,IAAI;QACX,MAAM,EAAE;YACN,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe;oBACrB,GAAG,EAAE,IAAA,4BAAkB,EAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iBACtF;gBACD;oBACE,IAAI,EAAE,gBAAgB;oBACtB,GAAG,EAAE,IAAA,4BAAkB,EAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iBAC3F;aACF;SACF;QACD,OAAO,EAAE,CAAC,IAAI,oCAAuB,CAAC,IAAI,CAAC,CAAC;KAC7C,CAAA;AACH,CAAC,CAAA;AApBY,QAAA,wBAAwB,4BAoBpC","sourcesContent":["import IgnoreEmitWebpackPlugin from 'ignore-emit-webpack-plugin'\n\nimport { styleConfigFactory } from '../loaders'\n\nexport const typedStylesConfigFactory = ({ raw, filesPaths }: { raw?: boolean; filesPaths: string[] }) => {\n return {\n mode: 'production',\n entry: { bundle: filesPaths },\n devtool: false,\n watch: true,\n module: {\n rules: [\n {\n test: /\\.(pcss|css)$/,\n use: styleConfigFactory({ raw, typedStyles: true, parser: 'postcss', modules: true }),\n },\n {\n test: /\\.(scss|sass)$/,\n use: styleConfigFactory({ raw, typedStyles: true, parser: 'postcss-scss', modules: true }),\n },\n ],\n },\n plugins: [new IgnoreEmitWebpackPlugin(/.+/)],\n }\n}\n"]}
|
package/index.js
CHANGED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,mDAAoC;AACpC,mDAAoC;AACpC,iBAAS;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAA","sourcesContent":["import * as loaders from './loaders'\nimport * as plugins from './plugins'\nimport * as configs from './configs'\nexport = {\n loaders,\n plugins,\n configs,\n}\n"]}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
const style_loader_1 = __importDefault(require("style-loader"));
|
|
6
6
|
const lodash_1 = require("lodash");
|
|
7
|
+
const cjs_1 = require("@enhanced-dom/css/cjs");
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
8
9
|
const loader = function () { };
|
|
9
10
|
loader.pitch = function pitch(remainingRequest) {
|
|
@@ -15,11 +16,12 @@ loader.pitch = function pitch(remainingRequest) {
|
|
|
15
16
|
if (index <= -1)
|
|
16
17
|
return result;
|
|
17
18
|
const insertIndex = index - 1;
|
|
18
|
-
const stylesheetName = (0, lodash_1.uniqueId)('stylesheet
|
|
19
|
+
const stylesheetName = (0, lodash_1.uniqueId)('stylesheet');
|
|
19
20
|
const insertAttr = `
|
|
20
21
|
options.attributes = options.attributes || {}
|
|
21
|
-
options.attributes.
|
|
22
|
+
options.attributes["${cjs_1.STYLESHEET_ATTRIBUTE_NAME}"] = "${stylesheetName}";
|
|
22
23
|
`;
|
|
23
24
|
return result.slice(0, insertIndex) + insertAttr + result.slice(insertIndex) + `export const _stylesheetName = "${stylesheetName}";`;
|
|
24
25
|
};
|
|
25
26
|
module.exports = loader;
|
|
27
|
+
//# sourceMappingURL=ExposeCssSourceLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExposeCssSourceLoader.js","sourceRoot":"./","sources":["loaders/ExposeCssSourceLoader.ts"],"names":[],"mappings":";;;;AAAA,gEAAsC;AACtC,mCAAiC;AACjC,+CAAiE;AAEjE,gEAAgE;AAChE,MAAM,MAAM,GAAG,cAAa,CAAC,CAAA;AAE7B,MAAM,CAAC,KAAK,GAAG,SAAS,KAAK,CAAC,gBAAwB;IACpD,IAAI,IAAI,CAAC,SAAS,EAAE;QAClB,IAAI,CAAC,SAAS,EAAE,CAAA;KACjB;IACD,MAAM,MAAM,GAAW,sBAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;IACrE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAA;IAClE,IAAI,KAAK,IAAI,CAAC,CAAC;QAAE,OAAO,MAAM,CAAA;IAC9B,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,CAAA;IAC7B,MAAM,cAAc,GAAG,IAAA,iBAAQ,EAAC,YAAY,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG;;0BAEK,+BAAyB,SAAS,cAAc;GACvE,CAAA;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,mCAAmC,cAAc,IAAI,CAAA;AACtI,CAAC,CAAA;AAED,iBAAS,MAAM,CAAA","sourcesContent":["import styleLoader from 'style-loader'\nimport { uniqueId } from 'lodash'\nimport { STYLESHEET_ATTRIBUTE_NAME } from '@enhanced-dom/css/cjs'\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst loader = function () {}\n\nloader.pitch = function pitch(remainingRequest: string) {\n if (this.cacheable) {\n this.cacheable()\n }\n const result: string = styleLoader.pitch.call(this, remainingRequest)\n const index = result.indexOf('var update = API(content, options)')\n if (index <= -1) return result\n const insertIndex = index - 1\n const stylesheetName = uniqueId('stylesheet')\n const insertAttr = `\n options.attributes = options.attributes || {}\n options.attributes[\"${STYLESHEET_ATTRIBUTE_NAME}\"] = \"${stylesheetName}\";\n `\n return result.slice(0, insertIndex) + insertAttr + result.slice(insertIndex) + `export const _stylesheetName = \"${stylesheetName}\";`\n}\n\nexport = loader\n"]}
|
package/loaders/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["loaders/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA0D;AAC1D,sGAA4D;AAC5D,MAAM,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAA;AACxE,4EAA2C;AAC3C,gFAA8C;AAC9C,8EAA6C;AAEtC,MAAM,kBAAkB,GAAG,CAAC,EACjC,GAAG,GAAG,KAAgB,EACtB,OAAO,GAAG,KAAK,EACf,SAAS,GAAG,KAAK,EACjB,WAAW,GAAG,KAAK,EACnB,OAAO,GAAG,SAEkD,EAC5D,MAAM,GAAG,SAAuC,EAChD,OAAO,GAAG,EAA4B,MACpC,EAAE,EAAE,EAAE;;IACR,MAAM,OAAO,GAAG,EAAE,CAAA;IAElB,IAAI,GAAG,EAAE;QAC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,OAAO,CAAA;AAChB,CAAC,CAAA;AAtBY,QAAA,qBAAqB,yBAsBjC","sourcesContent":["import MiniCssExtractPlugin from 'mini-css-extract-plugin'\nimport createResolver from 'postcss-import-webpack-resolver'\nconst ExposeCssSourceLoader = require.resolve('./ExposeCssSourceLoader')\nimport codeImport from 'remark-code-import'\nimport imageUnwrap from 'remark-unwrap-images'\nimport imageImport from 'remark-embed-images'\n\nexport const styleConfigFactory = ({\n raw = false as boolean,\n extract = false,\n sourceMap = false,\n typedStyles = false,\n modules = undefined as\n | { localIdentName?: string; mappings?: { filter: string; transform: (p: string) => string }[] }\n | (boolean & { localIdentName?: never; mappings?: never }),\n parser = undefined as 'postcss' | 'postcss-scss',\n aliases = {} as Record<string, string>,\n} = {}) => {\n const loaders = []\n\n if (raw) {\n loaders.push({\n loader: ExposeCssSourceLoader,\n options: {\n attributes: {},\n },\n })\n } else if (extract) {\n loaders.push({\n loader: MiniCssExtractPlugin.loader,\n options: {\n publicPath: './',\n },\n })\n } else {\n loaders.push({ loader: 'style-loader' })\n }\n\n if (typedStyles) {\n loaders.push({\n loader: 'dts-css-modules-loader',\n options: {\n namedExport: true,\n banner: raw ? 'export const _stylesheetName: string;' : undefined,\n },\n })\n }\n\n const cssLoader = {\n loader: 'css-loader',\n options: {\n sourceMap,\n ...(modules || typedStyles\n ? {\n esModule: true,\n modules: {\n localIdentName: modules?.localIdentName ?? '[local]_[hash:base64:5]',\n getLocalIdent: (loaderContext: { resourcePath: string }, _: any, localName: string) => {\n const { resourcePath } = loaderContext\n const mappings = modules?.mappings ?? []\n const mapping = mappings.find(({ filter }) => resourcePath.includes(filter))\n if (!mapping) {\n return undefined // this will trigger the default css-loader getLocalIdent function\n }\n return mapping.transform(localName)\n },\n exportLocalsConvention: 'camelCaseOnly',\n namedExport: true,\n },\n sourceMap,\n }\n : { modules: false }),\n },\n }\n\n loaders.push(cssLoader)\n\n const resolveUrlLoader = {\n loader: 'resolve-url-loader',\n }\n\n loaders.push(resolveUrlLoader)\n\n const postcssLoader = {\n loader: 'postcss-loader',\n options: {\n sourceMap: true,\n postcssOptions: {\n parser,\n plugins: [\n [\n 'postcss-import',\n {\n resolve: createResolver({\n alias: aliases,\n }),\n modules: ['./node_modules', 'node_modules'],\n },\n ],\n 'postcss-advanced-variables',\n 'postcss-nested',\n 'autoprefixer',\n // ['postcss-preset-env', {\n // browsers: ['last 2 versions']\n // }]\n ],\n },\n },\n }\n\n loaders.push(postcssLoader)\n\n return loaders\n}\n\nexport const nullConfigFactory = ({ rules = [] as RegExp[] } = {}) => {\n return rules.map((rule) => ({\n test: rule,\n use: 'null-loader',\n enforce: 'post',\n }))\n}\n\nexport const fontExtensions = ['ttf', 'eot', 'woff', 'woff2']\nexport const imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'ico']\nexport const assetExtensions = (extensions = [...imageExtensions, ...fontExtensions] as string[]) =>\n new RegExp(`\\\\.(${extensions.join('|')})(\\\\?.*$|$)?$`)\n\nexport const babelConfigFactory = ({ babel = undefined as any }) => {\n const loaders = [{ loader: 'babel-loader', options: babel }]\n return loaders\n}\n\nexport const markdownConfigFactory = ({ babel, remark = [] }: { babel?: any; remark?: any[] } = {}) => {\n const loaders = []\n\n if (babel) {\n loaders.push(...babelConfigFactory({ babel }))\n loaders.push({\n loader: '@mdx-js/loader',\n options: {\n remarkPlugins: [codeImport, imageImport, imageUnwrap, ...remark],\n },\n })\n } else {\n loaders.push(\n {\n loader: 'html-loader',\n },\n {\n loader: 'markdown-loader',\n },\n )\n }\n return loaders\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enhanced-dom/webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Helpers for webpack configuration",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": "https://github.com/enhanced-dom/webpack.git",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@enhanced-dom/build": "^0.0.1",
|
|
12
|
+
"@enhanced-dom/css": "^0.0.2",
|
|
12
13
|
"@mdx-js/loader": "^2.1.1",
|
|
13
14
|
"autoprefixer": "^10.3.5",
|
|
14
15
|
"babel-loader": "^8.2.2",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HtmlWebpackInlineSourcePlugin.js","sourceRoot":"./","sources":["plugins/HtmlWebpackInlineSourcePlugin.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,8EAA8D;AAC9D,0GAA6E;AAG7E,4CAAmB;AACnB,gDAAuB;AAIvB,2CAA6B,CAAC,SAAS,CAAC,WAAW,GAAG,UACpD,WAAwB,EACxB,UAAyE;IAEzE,MAAM,IAAI,GAAG,IAAI,CAAA;IAEjB,MAAM,QAAQ,GAAG,EAAE,CAAA;IACnB,MAAM,QAAQ,GAAG,EAAE,CAAA;IAEnB,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAA;IACrE,CAAC,CAAC,CAAA;IAEF,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAA;IACrE,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;AAC9C,CAAC,CAAA;AAED,2CAA6B,CAAC,SAAS,CAAC,KAAK,GAAG,UAAU,QAAkB;IAC1E,MAAM,IAAI,GAAG,IAAI,CAAA;IACjB,IAAI,CAAC,YAAY,G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E,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI;;gBACpD,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,MAAK,MAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,0CAAE,GAAG,EAAE,CAAA,EAAE;oBACtF,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;iBAChC;YACH,CAAC,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,iBAAS,2CAA6B,CAAA","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport HtmlWebpackPlugin, { Hooks } from 'html-webpack-plugin'\nimport HtmlWebpackInlineSourcePlugin from 'html-webpack-inline-source-plugin'\nimport { Compilation, Compiler } from 'webpack'\nimport { AsyncSeriesWaterfallHook } from 'tapable'\nimport fs from 'fs'\nimport path from 'path'\n\ntype AsyncSeriesWaterfallHookData<T> = T extends AsyncSeriesWaterfallHook<infer R> ? R : never\n\nHtmlWebpackInlineSourcePlugin.prototype.processTags = function (\n compilation: Compilation,\n pluginData: AsyncSeriesWaterfallHookData<Hooks['afterTemplateExecution']>,\n) {\n const self = this\n\n const headTags = []\n const bodyTags = []\n\n pluginData.headTags.forEach((tag) => {\n headTags.push(self.processTag(compilation, self.assetsRegExp, tag))\n })\n\n pluginData.bodyTags.forEach((tag) => {\n bodyTags.push(self.processTag(compilation, self.assetsRegExp, tag))\n })\n\n return { ...pluginData, headTags, bodyTags }\n}\n\nHtmlWebpackInlineSourcePlugin.prototype.apply = function (compiler: Compiler) {\n const self = this\n self.assetsRegExp = undefined\n self.faviconPath = undefined\n\n compiler.hooks.compilation.tap('html-webpack-inline-source-plugin', (compilation) => {\n HtmlWebpackPlugin.getHooks(compilation).afterTemplateExecution.tapAsync(\n 'html-webpack-inline-source-plugin',\n (htmlPluginData, callback) => {\n self.assetsRegExp = new RegExp('.(js|css)$')\n const result = self.processTags(compilation, htmlPluginData) as typeof htmlPluginData\n const favicon = htmlPluginData.plugin.options.favicon\n if (!favicon || !fs.existsSync(favicon)) {\n return callback(null, result)\n }\n const faviconTag = result.headTags.find((tag) => tag.tagName === 'link' && tag.attributes.rel === 'icon')\n if (faviconTag) {\n self.faviconPath = faviconTag.attributes.href as string\n faviconTag.attributes.href = `data:image/x-icon;base64, ${fs.readFileSync(favicon, 'base64')}`\n }\n callback(null, result)\n },\n )\n })\n\n compiler.hooks.emit.tap('html-webpack-inline-source-plugin', (compilation) => {\n if (self.assetsRegExp) {\n Object.keys(compilation.assets).forEach(function (file) {\n if (file.match(self.assetsRegExp) || file === self.faviconPath?.split(path.sep)?.pop()) {\n delete compilation.assets[file]\n }\n })\n }\n })\n}\n\nexport = HtmlWebpackInlineSourcePlugin\n"]}
|
package/plugins/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["plugins/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,qEAA8D;AAC9D,gGAA6D;AAC7D,sFAA0D;AAC1D,kFAAgD;AAEhD,8EAAmD;AACnD,4CAAmB;AAGnB,oGAAoE;AAE7D,MAAM,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,GAAG,wBAAwB,EACnC,cAAc,GAAG,EAAE,MAC4B,EAAE,EAAE,EAAE;IACrD,OAAO;QACL,IAAI,iCAAoB,CAAC;YACvB,QAAQ;SACT,CAAC;QACF,IAAI,sCAAkB,CAAC;YACrB,IAAI,EAAE,SAAS;YACf,gBAAgB,EAAE;gBAChB,MAAM,EAAE,CAAC,UAAU,CAAC;gBACpB,GAAG,cAAc;aAClB;YACD,MAAM,EAAE,sCAAkB,CAAC,aAAa;SACzC,CAAC;KACH,CAAA;AACH,CAAC,CAAA;AAjBY,QAAA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;KAC3C;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AA5BY,QAAA,iBAAiB,qBA4B7B;AAEM,MAAM,mBAAmB,GAAG,CAAC,EAAE,gBAAgB,GAAG,IAAI,EAAE,aAAa,GAAG,EAAmB,KAAK,EAAE,EAAE,EAAE,CAAC;IAC5G,yDAAyD;IACzD,IAAI,+BAAY,CAAC;QACf,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE;YACb,GAAG,EAAE,KAAK;YACV,SAAS,EAAE,gBAAgB;YAC3B,QAAQ,EAAE;gBACR,QAAQ,EAAE,KAAK;aAChB;YACD,WAAW,EAAE,IAAI;YACjB,eAAe,EAAE,IAAI;YACrB,MAAM,EAAE;gBACN,WAAW,EAAE,IAAI;gBACjB,eAAe,EAAE,IAAI;aACtB;YACD,GAAG,aAAa;SACjB;KACF,CAAC;CACH,CAAA;AAnBY,QAAA,mBAAmB,uBAmB/B","sourcesContent":["import path from 'path'\nimport { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin'\nimport MiniCssExtractPlugin from 'mini-css-extract-plugin'\nimport TerserPlugin from 'terser-webpack-plugin'\nimport { MinifyOptions } from 'terser'\nimport HtmlWebpackPlugin from 'html-webpack-plugin'\nimport fs from 'fs'\nimport { WebpackPluginInstance } from 'webpack'\n\nimport HtmlInlineSourcePlugin from './HtmlWebpackInlineSourcePlugin'\n\nexport const cssConfigFactory = ({\n filename = '[name]-[chunkhash].css',\n cssnanoOptions = {},\n}: { filename?: string; cssnanoOptions?: any } = {}) => {\n return [\n new MiniCssExtractPlugin({\n filename,\n }),\n new CssMinimizerPlugin({\n test: /\\.css$/g,\n minimizerOptions: {\n preset: ['advanced'],\n ...cssnanoOptions,\n },\n minify: CssMinimizerPlugin.cssnanoMinify,\n }),\n ]\n}\n\nexport const bundleAnalyzerConfigFactory = (extraConfig: BundleAnalyzerPlugin.Options = {}) => {\n return [\n new BundleAnalyzerPlugin({\n analyzerMode: 'static',\n reportFilename: './reports/bundle-analysis.html',\n openAnalyzer: false,\n ...extraConfig,\n }),\n ]\n}\n\nexport const htmlConfigFactory = ({ html = {}, embed }: { embed?: boolean; html?: Partial<HtmlWebpackPlugin.Options> } = {}) => {\n const template = html.template ?? path.join(process.cwd(), 'template.html')\n const templateExists = fs.existsSync(template)\n const templateContent = `<!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n </html>`\n const favicon = html.favicon ? (path.isAbsolute(html.favicon) ? html.favicon : path.join(process.cwd(), html.favicon)) : undefined\n const plugins: WebpackPluginInstance[] = [\n new HtmlWebpackPlugin({\n inject: 'body',\n lang: 'en-US',\n ...(templateExists ? { template } : { templateContent }),\n ...html,\n favicon,\n }),\n ]\n\n if (embed) {\n plugins.push(new HtmlInlineSourcePlugin())\n }\n\n return plugins\n}\n\nexport const terserConfigFactory = ({ enableSourcemaps = true, terserOptions = {} as MinifyOptions } = {}) => [\n /* eslint-disable @typescript-eslint/naming-convention */\n new TerserPlugin({\n parallel: true,\n terserOptions: {\n ie8: false,\n sourceMap: enableSourcemaps,\n compress: {\n evaluate: false,\n },\n keep_fnames: true,\n keep_classnames: true,\n mangle: {\n keep_fnames: true,\n keep_classnames: true,\n },\n ...terserOptions,\n },\n }),\n]\n"]}
|