@enhanced-dom/webpack 0.0.4 → 0.0.5
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/config.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -22,5 +26,5 @@ const loaders = __importStar(require("./loaders"));
|
|
|
22
26
|
const plugins = __importStar(require("./plugins"));
|
|
23
27
|
module.exports = {
|
|
24
28
|
loaders,
|
|
25
|
-
plugins
|
|
29
|
+
plugins,
|
|
26
30
|
};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const style_loader_1 = __importDefault(require("style-loader"));
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
2
7
|
const loader = function () { };
|
|
3
|
-
const styleLoader = require('style-loader');
|
|
4
|
-
const uniqueId = require('lodash').uniqueId;
|
|
5
8
|
loader.pitch = function pitch(remainingRequest) {
|
|
6
9
|
if (this.cacheable) {
|
|
7
10
|
this.cacheable();
|
|
8
11
|
}
|
|
9
|
-
const result =
|
|
12
|
+
const result = style_loader_1.default.pitch.call(this, remainingRequest);
|
|
10
13
|
const index = result.indexOf('var update = API(content, options)');
|
|
11
14
|
if (index <= -1)
|
|
12
15
|
return result;
|
|
13
16
|
const insertIndex = index - 1;
|
|
14
|
-
const stylesheetName = uniqueId('stylesheet-');
|
|
17
|
+
const stylesheetName = (0, lodash_1.uniqueId)('stylesheet-');
|
|
15
18
|
const insertAttr = `
|
|
16
19
|
options.attributes = options.attributes || {}
|
|
17
20
|
options.attributes.title = "${stylesheetName}";
|
package/loaders/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare const babelConfigFactory: ({ babel }: {
|
|
|
29
29
|
loader: string;
|
|
30
30
|
options: any;
|
|
31
31
|
}[];
|
|
32
|
-
export declare const markdownConfigFactory: ({ babel, remark
|
|
32
|
+
export declare const markdownConfigFactory: ({ babel, remark }?: {
|
|
33
33
|
babel?: any;
|
|
34
34
|
remark?: any[];
|
|
35
35
|
}) => any[];
|
package/loaders/index.js
CHANGED
|
@@ -7,11 +7,8 @@ exports.markdownConfigFactory = exports.babelConfigFactory = exports.assetExtens
|
|
|
7
7
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
8
8
|
const postcss_import_webpack_resolver_1 = __importDefault(require("postcss-import-webpack-resolver"));
|
|
9
9
|
const ExposeCssSourceLoader = require.resolve('./ExposeCssSourceLoader');
|
|
10
|
-
// @ts-ignore
|
|
11
10
|
const remark_code_import_1 = __importDefault(require("remark-code-import"));
|
|
12
|
-
// @ts-ignore
|
|
13
11
|
const remark_unwrap_images_1 = __importDefault(require("remark-unwrap-images"));
|
|
14
|
-
// @ts-ignore
|
|
15
12
|
const remark_embed_images_1 = __importDefault(require("remark-embed-images"));
|
|
16
13
|
const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, typedStyles = false, modules = undefined, parser = undefined, aliases = {}, } = {}) => {
|
|
17
14
|
var _a;
|
|
@@ -20,8 +17,8 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
20
17
|
loaders.push({
|
|
21
18
|
loader: ExposeCssSourceLoader,
|
|
22
19
|
options: {
|
|
23
|
-
attributes: {}
|
|
24
|
-
}
|
|
20
|
+
attributes: {},
|
|
21
|
+
},
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
24
|
else if (extract) {
|
|
@@ -29,7 +26,7 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
29
26
|
loader: mini_css_extract_plugin_1.default.loader,
|
|
30
27
|
options: {
|
|
31
28
|
publicPath: './',
|
|
32
|
-
}
|
|
29
|
+
},
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
32
|
else {
|
|
@@ -85,7 +82,7 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
85
82
|
[
|
|
86
83
|
'postcss-import',
|
|
87
84
|
{
|
|
88
|
-
resolve: postcss_import_webpack_resolver_1.default({
|
|
85
|
+
resolve: (0, postcss_import_webpack_resolver_1.default)({
|
|
89
86
|
alias: aliases,
|
|
90
87
|
}),
|
|
91
88
|
modules: ['./node_modules', 'node_modules'],
|
|
@@ -122,10 +119,10 @@ const babelConfigFactory = ({ babel = undefined }) => {
|
|
|
122
119
|
return loaders;
|
|
123
120
|
};
|
|
124
121
|
exports.babelConfigFactory = babelConfigFactory;
|
|
125
|
-
const markdownConfigFactory = ({ babel, remark = []
|
|
122
|
+
const markdownConfigFactory = ({ babel, remark = [] } = {}) => {
|
|
126
123
|
const loaders = [];
|
|
127
124
|
if (babel) {
|
|
128
|
-
loaders.push(...exports.babelConfigFactory({ babel }));
|
|
125
|
+
loaders.push(...(0, exports.babelConfigFactory)({ babel }));
|
|
129
126
|
loaders.push({
|
|
130
127
|
loader: '@mdx-js/loader',
|
|
131
128
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enhanced-dom/webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Helpers for webpack configuration",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": "https://github.com/enhanced-dom/webpack.git",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"source-map-loader": "^3.0.0",
|
|
51
51
|
"style-loader": "^3.2.1",
|
|
52
52
|
"terser-webpack-plugin": "^5.1.2",
|
|
53
|
-
"webpack": "^5.
|
|
54
|
-
"webpack-bundle-analyzer": "^4.
|
|
55
|
-
"webpack-cli": "^4.
|
|
56
|
-
"webpack-dev-server": "^4.
|
|
53
|
+
"webpack": "^5.70.0",
|
|
54
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
55
|
+
"webpack-cli": "^4.9.2",
|
|
56
|
+
"webpack-dev-server": "^4.7.4",
|
|
57
57
|
"serve": "^12.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
@@ -62,17 +62,16 @@
|
|
|
62
62
|
"@types/loader-utils": "^2.0.2",
|
|
63
63
|
"@types/mini-css-extract-plugin": "^1.4.3",
|
|
64
64
|
"@types/optimize-css-assets-webpack-plugin": "^5.0.3",
|
|
65
|
-
"@types/terser-webpack-plugin": "^5.0
|
|
65
|
+
"@types/terser-webpack-plugin": "^5.2.0",
|
|
66
66
|
"@types/webpack": "^5.28.0",
|
|
67
67
|
"@types/webpack-bundle-analyzer": "^2.9.2",
|
|
68
68
|
"typescript": "^4.2.2"
|
|
69
|
-
|
|
70
69
|
},
|
|
71
70
|
"overrides": {
|
|
72
71
|
"postcss": "^8.2.15",
|
|
73
72
|
"postcss-scss": "^4.0.0",
|
|
74
73
|
"autoprefixer": "^10.3.5",
|
|
75
|
-
"
|
|
74
|
+
"terser": "^5.12.1"
|
|
76
75
|
},
|
|
77
76
|
"engines": {
|
|
78
77
|
"node": ">=14.17.0",
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
6
|
-
// @ts-ignore
|
|
7
6
|
const html_webpack_inline_source_plugin_1 = __importDefault(require("html-webpack-inline-source-plugin"));
|
|
8
7
|
const fs_1 = __importDefault(require("fs"));
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
@@ -31,7 +30,7 @@ html_webpack_inline_source_plugin_1.default.prototype.apply = function (compiler
|
|
|
31
30
|
if (!favicon || !fs_1.default.existsSync(favicon)) {
|
|
32
31
|
return callback(null, result);
|
|
33
32
|
}
|
|
34
|
-
const faviconTag = result.headTags.find(tag => tag.tagName === 'link' && tag.attributes.rel === 'icon');
|
|
33
|
+
const faviconTag = result.headTags.find((tag) => tag.tagName === 'link' && tag.attributes.rel === 'icon');
|
|
35
34
|
if (faviconTag) {
|
|
36
35
|
self.faviconPath = faviconTag.attributes.href;
|
|
37
36
|
faviconTag.attributes.href = `data:image/x-icon;base64, ${fs_1.default.readFileSync(favicon, 'base64')}`;
|
package/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
2
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
2
4
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
3
5
|
import { MinifyOptions } from 'terser';
|
|
4
6
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
@@ -6,14 +8,13 @@ import { WebpackPluginInstance } from 'webpack';
|
|
|
6
8
|
export declare const cssConfigFactory: ({ filename, cssnanoOptions, }?: {
|
|
7
9
|
filename?: string;
|
|
8
10
|
cssnanoOptions?: any;
|
|
9
|
-
}) =>
|
|
11
|
+
}) => (MiniCssExtractPlugin | CssMinimizerPlugin<CssMinimizerPlugin.CssNanoOptionsExtended>)[];
|
|
10
12
|
export declare const bundleAnalyzerConfigFactory: (extraConfig?: BundleAnalyzerPlugin.Options) => BundleAnalyzerPlugin[];
|
|
11
|
-
export declare const htmlConfigFactory: ({ html, embed
|
|
13
|
+
export declare const htmlConfigFactory: ({ html, embed }?: {
|
|
12
14
|
embed?: boolean;
|
|
13
15
|
html?: Partial<HtmlWebpackPlugin.Options>;
|
|
14
|
-
outputPath?: string;
|
|
15
16
|
}) => WebpackPluginInstance[];
|
|
16
|
-
export declare const terserConfigFactory: ({ enableSourcemaps, terserOptions
|
|
17
|
+
export declare const terserConfigFactory: ({ enableSourcemaps, terserOptions }?: {
|
|
17
18
|
enableSourcemaps?: boolean;
|
|
18
19
|
terserOptions?: MinifyOptions;
|
|
19
|
-
}) => TerserPlugin[];
|
|
20
|
+
}) => TerserPlugin<MinifyOptions>[];
|
package/plugins/index.js
CHANGED
|
@@ -39,7 +39,7 @@ const bundleAnalyzerConfigFactory = (extraConfig = {}) => {
|
|
|
39
39
|
];
|
|
40
40
|
};
|
|
41
41
|
exports.bundleAnalyzerConfigFactory = bundleAnalyzerConfigFactory;
|
|
42
|
-
const htmlConfigFactory = ({ html = {}, embed
|
|
42
|
+
const htmlConfigFactory = ({ html = {}, embed } = {}) => {
|
|
43
43
|
var _a;
|
|
44
44
|
const template = (_a = html.template) !== null && _a !== void 0 ? _a : path_1.default.join(process.cwd(), 'template.html');
|
|
45
45
|
const templateExists = fs_1.default.existsSync(template);
|
|
@@ -59,7 +59,7 @@ const htmlConfigFactory = ({ html = {}, embed, outputPath = './dist' } = {}) =>
|
|
|
59
59
|
lang: 'en-US',
|
|
60
60
|
...(templateExists ? { template } : { templateContent }),
|
|
61
61
|
...html,
|
|
62
|
-
favicon
|
|
62
|
+
favicon,
|
|
63
63
|
}),
|
|
64
64
|
];
|
|
65
65
|
if (embed) {
|
|
@@ -68,13 +68,12 @@ const htmlConfigFactory = ({ html = {}, embed, outputPath = './dist' } = {}) =>
|
|
|
68
68
|
return plugins;
|
|
69
69
|
};
|
|
70
70
|
exports.htmlConfigFactory = htmlConfigFactory;
|
|
71
|
-
const terserConfigFactory = ({ enableSourcemaps = true, terserOptions = {}
|
|
71
|
+
const terserConfigFactory = ({ enableSourcemaps = true, terserOptions = {} } = {}) => [
|
|
72
72
|
new terser_webpack_plugin_1.default({
|
|
73
73
|
parallel: true,
|
|
74
|
-
cache: true,
|
|
75
|
-
sourceMap: enableSourcemaps,
|
|
76
74
|
terserOptions: {
|
|
77
75
|
ie8: false,
|
|
76
|
+
sourceMap: enableSourcemaps,
|
|
78
77
|
compress: {
|
|
79
78
|
evaluate: false,
|
|
80
79
|
},
|