@enhanced-dom/webpack 0.1.0 → 0.2.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.
- package/configs/index.d.ts +6 -3
- package/configs/index.js +9 -7
- package/configs/index.js.map +1 -1
- package/loaders/WebcomponentStyleLoader.d.ts +5 -0
- package/loaders/WebcomponentStyleLoader.js +70 -0
- package/loaders/WebcomponentStyleLoader.js.map +1 -0
- package/loaders/index.js +35 -25
- package/loaders/index.js.map +1 -1
- package/package.json +5 -6
- package/loaders/ExposeCssSourceLoader.d.ts +0 -5
- package/loaders/ExposeCssSourceLoader.js +0 -27
- package/loaders/ExposeCssSourceLoader.js.map +0 -1
package/configs/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import IgnoreEmitWebpackPlugin from 'ignore-emit-webpack-plugin';
|
|
2
|
-
export declare const typedStylesConfigFactory: ({ raw,
|
|
2
|
+
export declare const typedStylesConfigFactory: ({ raw, filePaths, outputPath }: {
|
|
3
3
|
raw?: boolean;
|
|
4
|
-
|
|
4
|
+
filePaths: string[];
|
|
5
|
+
outputPath?: string;
|
|
5
6
|
}) => {
|
|
6
7
|
mode: string;
|
|
7
8
|
entry: {
|
|
8
9
|
bundle: string[];
|
|
9
10
|
};
|
|
10
11
|
devtool: boolean;
|
|
11
|
-
|
|
12
|
+
output: {
|
|
13
|
+
path: string;
|
|
14
|
+
};
|
|
12
15
|
module: {
|
|
13
16
|
rules: {
|
|
14
17
|
test: RegExp;
|
package/configs/index.js
CHANGED
|
@@ -5,26 +5,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.typedStylesConfigFactory = void 0;
|
|
7
7
|
const ignore_emit_webpack_plugin_1 = __importDefault(require("ignore-emit-webpack-plugin"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const loaders_1 = require("../loaders");
|
|
9
|
-
const typedStylesConfigFactory = ({ raw,
|
|
10
|
+
const typedStylesConfigFactory = ({ raw, filePaths, outputPath }) => {
|
|
11
|
+
const fileRegexes = filePaths.map((filePath) => new RegExp(`^((?!${path_1.default.basename(filePath).replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}).)*$`));
|
|
10
12
|
return {
|
|
11
|
-
mode: '
|
|
12
|
-
entry: { bundle:
|
|
13
|
+
mode: 'development',
|
|
14
|
+
entry: { bundle: filePaths },
|
|
13
15
|
devtool: false,
|
|
14
|
-
|
|
16
|
+
output: outputPath ? { path: outputPath } : undefined,
|
|
15
17
|
module: {
|
|
16
18
|
rules: [
|
|
17
19
|
{
|
|
18
20
|
test: /\.(pcss|css)$/,
|
|
19
|
-
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss',
|
|
21
|
+
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss', extract: !!outputPath }),
|
|
20
22
|
},
|
|
21
23
|
{
|
|
22
24
|
test: /\.(scss|sass)$/,
|
|
23
|
-
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss-scss',
|
|
25
|
+
use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss-scss', extract: !!outputPath }),
|
|
24
26
|
},
|
|
25
27
|
],
|
|
26
28
|
},
|
|
27
|
-
plugins: [new ignore_emit_webpack_plugin_1.default(
|
|
29
|
+
plugins: [new ignore_emit_webpack_plugin_1.default(fileRegexes)],
|
|
28
30
|
};
|
|
29
31
|
};
|
|
30
32
|
exports.typedStylesConfigFactory = typedStylesConfigFactory;
|
package/configs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./","sources":["configs/index.ts"],"names":[],"mappings":";;;;;;AAAA,4FAAgE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["configs/index.ts"],"names":[],"mappings":";;;;;;AAAA,4FAAgE;AAChE,gDAAuB;AAEvB,wCAA+C;AAExC,MAAM,wBAAwB,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAA+D,EAAE,EAAE;IACtI,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAC/B,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,OAAO,CAAC,CAC7G,CAAA;IACD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;QAC5B,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS;QACrD,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,CAAC,CAAC,UAAU,EAAE,CAAC;iBAC9F;gBACD;oBACE,IAAI,EAAE,gBAAgB;oBACtB,GAAG,EAAE,IAAA,4BAAkB,EAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;iBACnG;aACF;SACF;QACD,OAAO,EAAE,CAAC,IAAI,oCAAuB,CAAC,WAAW,CAAC,CAAC;KACpD,CAAA;AACH,CAAC,CAAA;AAvBY,QAAA,wBAAwB,4BAuBpC","sourcesContent":["import IgnoreEmitWebpackPlugin from 'ignore-emit-webpack-plugin'\nimport path from 'path'\n\nimport { styleConfigFactory } from '../loaders'\n\nexport const typedStylesConfigFactory = ({ raw, filePaths, outputPath }: { raw?: boolean; filePaths: string[]; outputPath?: string }) => {\n const fileRegexes = filePaths.map(\n (filePath) => new RegExp(`^((?!${path.basename(filePath).replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&')}).)*$`),\n )\n return {\n mode: 'development',\n entry: { bundle: filePaths },\n devtool: false,\n output: outputPath ? { path: outputPath } : undefined,\n module: {\n rules: [\n {\n test: /\\.(pcss|css)$/,\n use: styleConfigFactory({ raw, typedStyles: true, parser: 'postcss', extract: !!outputPath }),\n },\n {\n test: /\\.(scss|sass)$/,\n use: styleConfigFactory({ raw, typedStyles: true, parser: 'postcss-scss', extract: !!outputPath }),\n },\n ],\n },\n plugins: [new IgnoreEmitWebpackPlugin(fileRegexes)],\n }\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const path_1 = __importDefault(require("path"));
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const schema_utils_1 = require("schema-utils");
|
|
8
|
+
const schema = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
pathPrefix: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
},
|
|
14
|
+
emit: {
|
|
15
|
+
type: 'boolean',
|
|
16
|
+
},
|
|
17
|
+
typings: {
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
},
|
|
20
|
+
raw: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
},
|
|
23
|
+
named: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
};
|
|
29
|
+
const loader = function (content) {
|
|
30
|
+
var _a;
|
|
31
|
+
const options = this.getOptions();
|
|
32
|
+
(0, schema_utils_1.validate)(schema, options, { name: 'webcomponent-styles' });
|
|
33
|
+
if (options.emit) {
|
|
34
|
+
const pathPrefix = (_a = options.pathPrefix) !== null && _a !== void 0 ? _a : path_1.default.join(process.cwd(), 'src');
|
|
35
|
+
const transformedAssetPath = path_1.default
|
|
36
|
+
.join(path_1.default.dirname(this.resourcePath), `${path_1.default.basename(this.resourcePath)}.js`)
|
|
37
|
+
.replace(pathPrefix, '');
|
|
38
|
+
const transformedCode = Object.entries(this.data)
|
|
39
|
+
.map(([exportName, exportValue]) => `export const ${exportName} = ${exportValue}`)
|
|
40
|
+
.join('\n');
|
|
41
|
+
this.emitFile(transformedAssetPath, transformedCode);
|
|
42
|
+
if (options.typings) {
|
|
43
|
+
const transformedDtsPath = path_1.default
|
|
44
|
+
.join(path_1.default.dirname(this.resourcePath), `${path_1.default.basename(this.resourcePath)}.d.ts`)
|
|
45
|
+
.replace(pathPrefix, '');
|
|
46
|
+
const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\n');
|
|
47
|
+
this.emitFile(transformedDtsPath, typingsCode);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (options.typings) {
|
|
51
|
+
const dtsPath = path_1.default.join(path_1.default.dirname(this.resourcePath), `${path_1.default.basename(this.resourcePath)}.d.ts`);
|
|
52
|
+
const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\n');
|
|
53
|
+
if (!fs_1.default.existsSync(dtsPath) || fs_1.default.readFileSync(dtsPath, 'utf-8') != typingsCode) {
|
|
54
|
+
fs_1.default.writeFileSync(dtsPath, typingsCode, 'utf8');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return options.raw ? content + `export var css = ${this.data.css};\n` : content;
|
|
58
|
+
};
|
|
59
|
+
loader.pitch = async function (request) {
|
|
60
|
+
const options = this.getOptions();
|
|
61
|
+
(0, schema_utils_1.validate)(schema, options, { name: 'webcomponent-styles' });
|
|
62
|
+
const result = await this.importModule(this.resourcePath + '.webpack[javascript/auto]' + '!=!' + request);
|
|
63
|
+
const { default: defaultExport, ...otherExports } = result;
|
|
64
|
+
if (options.raw) {
|
|
65
|
+
this.data.css = `\`${defaultExport.toString()}\``;
|
|
66
|
+
}
|
|
67
|
+
Object.entries(otherExports).forEach(([exportName, exportValue]) => (this.data[exportName] = `'${exportValue.replace(/^["|'](.+)["|']$/, '$1')}'`));
|
|
68
|
+
};
|
|
69
|
+
module.exports = loader;
|
|
70
|
+
//# sourceMappingURL=WebcomponentStyleLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebcomponentStyleLoader.js","sourceRoot":"./","sources":["loaders/WebcomponentStyleLoader.ts"],"names":[],"mappings":";;;;AAAA,gDAAuB;AACvB,4CAAmB;AACnB,+CAAuC;AAGvC,MAAM,MAAM,GAAgB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;SACf;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;SAChB;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;SAChB;QACD,GAAG,EAAE;YACH,IAAI,EAAE,SAAS;SAChB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;SAChB;KACF;IACD,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,MAAM,GAAG,UAAU,OAAe;;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;IACjC,IAAA,uBAAQ,EAAC,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAA;IAE1D,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAA;QACxE,MAAM,oBAAoB,GAAG,cAAI;aAC9B,IAAI,CAAC,cAAI,CAAC,O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C,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG,CAAC,CAChI,CAAA;AACH,CAAC,CAAA;AAED,iBAAS,MAAM,CAAA","sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport { validate } from 'schema-utils'\nimport { type JSONSchema7 } from 'json-schema' // eslint-disable-line import/no-unresolved\n\nconst schema: JSONSchema7 = {\n type: 'object',\n properties: {\n pathPrefix: {\n type: 'string',\n },\n emit: {\n type: 'boolean',\n },\n typings: {\n type: 'boolean',\n },\n raw: {\n type: 'boolean',\n },\n named: {\n type: 'boolean',\n },\n },\n additionalProperties: false,\n}\n\nconst loader = function (content: string) {\n const options = this.getOptions()\n validate(schema, options, { name: 'webcomponent-styles' })\n\n if (options.emit) {\n const pathPrefix = options.pathPrefix ?? path.join(process.cwd(), 'src')\n const transformedAssetPath = path\n .join(path.dirname(this.resourcePath), `${path.basename(this.resourcePath)}.js`)\n .replace(pathPrefix, '')\n const transformedCode = Object.entries(this.data)\n .map(([exportName, exportValue]: [string, string]) => `export const ${exportName} = ${exportValue}`)\n .join('\\n')\n this.emitFile(transformedAssetPath, transformedCode)\n if (options.typings) {\n const transformedDtsPath = path\n .join(path.dirname(this.resourcePath), `${path.basename(this.resourcePath)}.d.ts`)\n .replace(pathPrefix, '')\n const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\\n')\n this.emitFile(transformedDtsPath, typingsCode)\n }\n }\n if (options.typings) {\n const dtsPath = path.join(path.dirname(this.resourcePath), `${path.basename(this.resourcePath)}.d.ts`)\n const typingsCode = [...Object.keys(this.data).map((exportName) => `export const ${exportName}: string;`)].join('\\n')\n if (!fs.existsSync(dtsPath) || fs.readFileSync(dtsPath, 'utf-8') != typingsCode) {\n fs.writeFileSync(dtsPath, typingsCode, 'utf8')\n }\n }\n\n return options.raw ? content + `export var css = ${this.data.css};\\n` : content\n}\n\nloader.pitch = async function (request: string) {\n const options = this.getOptions()\n validate(schema, options, { name: 'webcomponent-styles' })\n const result = await this.importModule(this.resourcePath + '.webpack[javascript/auto]' + '!=!' + request)\n const { default: defaultExport, ...otherExports } = result\n if (options.raw) {\n this.data.css = `\\`${defaultExport.toString()}\\``\n }\n Object.entries(otherExports).forEach(\n ([exportName, exportValue]: [string, string]) => (this.data[exportName] = `'${exportValue.replace(/^[\"|'](.+)[\"|']$/, '$1')}'`),\n )\n}\n\nexport = loader\n"]}
|
package/loaders/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.markdownConfigFactory = exports.babelConfigFactory = exports.assetExtensions = exports.imageExtensions = exports.fontExtensions = exports.nullConfigFactory = exports.styleConfigFactory = void 0;
|
|
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
|
-
const
|
|
9
|
+
const WebcomponentStyleLoader = require.resolve('./WebcomponentStyleLoader');
|
|
10
10
|
const remark_code_import_1 = __importDefault(require("remark-code-import"));
|
|
11
11
|
const remark_unwrap_images_1 = __importDefault(require("remark-unwrap-images"));
|
|
12
12
|
const remark_embed_images_1 = __importDefault(require("remark-embed-images"));
|
|
@@ -15,31 +15,36 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
15
15
|
const loaders = [];
|
|
16
16
|
if (raw) {
|
|
17
17
|
loaders.push({
|
|
18
|
-
loader:
|
|
18
|
+
loader: WebcomponentStyleLoader,
|
|
19
19
|
options: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
else if (extract) {
|
|
25
|
-
loaders.push({
|
|
26
|
-
loader: mini_css_extract_plugin_1.default.loader,
|
|
27
|
-
options: {
|
|
28
|
-
publicPath: './',
|
|
20
|
+
raw: true,
|
|
21
|
+
emit: extract,
|
|
22
|
+
typings: typedStyles,
|
|
29
23
|
},
|
|
30
24
|
});
|
|
31
25
|
}
|
|
32
26
|
else {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
if (extract) {
|
|
28
|
+
loaders.push({
|
|
29
|
+
loader: mini_css_extract_plugin_1.default.loader,
|
|
30
|
+
options: {
|
|
31
|
+
publicPath: './',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
loaders.push({ loader: 'style-loader' });
|
|
37
|
+
}
|
|
38
|
+
if (typedStyles) {
|
|
39
|
+
loaders.push({
|
|
40
|
+
loader: WebcomponentStyleLoader,
|
|
41
|
+
options: {
|
|
42
|
+
raw: false,
|
|
43
|
+
emit: false,
|
|
44
|
+
typings: true,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
const cssLoader = {
|
|
45
50
|
loader: 'css-loader',
|
|
@@ -80,6 +85,8 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
80
85
|
postcssOptions: {
|
|
81
86
|
parser,
|
|
82
87
|
plugins: [
|
|
88
|
+
'postcss-normalize-whitespace',
|
|
89
|
+
'postcss-discard-comments',
|
|
83
90
|
[
|
|
84
91
|
'postcss-import',
|
|
85
92
|
{
|
|
@@ -90,10 +97,13 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
|
|
|
90
97
|
},
|
|
91
98
|
],
|
|
92
99
|
'postcss-nested',
|
|
93
|
-
'autoprefixer',
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
// 'autoprefixer',
|
|
101
|
+
[
|
|
102
|
+
'postcss-preset-env',
|
|
103
|
+
{
|
|
104
|
+
stage: 3,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
97
107
|
],
|
|
98
108
|
},
|
|
99
109
|
},
|
package/loaders/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./","sources":["loaders/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA0D;AAC1D,sGAA4D;AAC5D,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["loaders/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA0D;AAC1D,sGAA4D;AAC5D,MAAM,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAA;AAC5E,4EAA2C;AAC3C,gFAA8C;AAC9C,8EAA6C;AAEtC,MAAM,kBAAkB,GAAG,CAAC,EACjC,GAAG,GAAG,KAAK,EACX,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,CAAC;QACR,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,uBAAuB;YAC/B,OAAO,EAAE;gBACP,GAAG,EAAE,IAAI;gBACT,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,WAAW;aACrB;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC;gBACX,MAAM,EAAE,iCAAoB,CAAC,MAAM;gBACnC,OAAO,EAAE;oBACP,UAAU,EAAE,IAAI;iBACjB;aACF,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAA;QAC1C,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAA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AC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAD3C,QAAA,eAAe,mBAC4B;AAEjD,MAAM,kBAAkB,GAAG,CAAC,EAAE,KAAK,GAAG,SAAgB,EAAE,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5D,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAHY,QAAA,kBAAkB,sBAG9B;AAEM,MAAM,qBAAqB,GAAG,CAAC,EACpC,KAAK,EACL,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,KAAK,MACuD,EAAE,EAAE,EAAE;IAChF,MAAM,OAAO,GAAG,EAAE,CAAA;IAElB,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,IAAI,CAAC,GAAG,IAAA,0BAAkB,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,gBAAgB;YACxB,OAAO,EAAE;gBACP,aAAa,EAAE,CAAC,4BAAU,EAAE,6BAAW,EAAE,8BAAW,EAAE,GAAG,MAAM,CAAC;gBAChE,aAAa,EAAE,MAAM;gBACrB,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;aAChE;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CACV;YACE,MAAM,EAAE,aAAa;SACtB,EACD;YACE,MAAM,EAAE,iBAAiB;SAC1B,CACF,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AA7BY,QAAA,qBAAqB,yBA6BjC","sourcesContent":["import MiniCssExtractPlugin from 'mini-css-extract-plugin'\nimport createResolver from 'postcss-import-webpack-resolver'\nconst WebcomponentStyleLoader = require.resolve('./WebcomponentStyleLoader')\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,\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: WebcomponentStyleLoader,\n options: {\n raw: true,\n emit: extract,\n typings: typedStyles,\n },\n })\n } else {\n 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: WebcomponentStyleLoader,\n options: {\n raw: false,\n emit: false,\n typings: true,\n },\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 'postcss-normalize-whitespace',\n 'postcss-discard-comments',\n [\n 'postcss-import',\n {\n resolve: createResolver({\n alias: aliases,\n }),\n modules: ['./node_modules', 'node_modules'],\n },\n ],\n 'postcss-nested',\n // 'autoprefixer',\n [\n 'postcss-preset-env',\n {\n stage: 3,\n },\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 = ({\n babel,\n remark = [],\n rehype = [],\n useProvider = false,\n}: { babel?: any; remark?: any[]; rehype?: any[]; useProvider?: boolean } = {}) => {\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 rehypePlugins: rehype,\n providerImportSource: useProvider ? '@mdx-js/react' : undefined,\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.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Helpers for webpack configuration",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": "https://github.com/enhanced-dom/webpack.git",
|
|
@@ -8,14 +8,11 @@
|
|
|
8
8
|
"author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@enhanced-dom/build": "
|
|
12
|
-
"@enhanced-dom/css": "^0.1.0",
|
|
11
|
+
"@enhanced-dom/build": "~0.1.0",
|
|
13
12
|
"@mdx-js/loader": "^3.0.0",
|
|
14
|
-
"autoprefixer": "^10.4.17",
|
|
15
13
|
"babel-loader": "^9.1.3",
|
|
16
14
|
"css-loader": "^6.10.0",
|
|
17
15
|
"cssnano-preset-advanced": "^6.0.3",
|
|
18
|
-
"dts-css-modules-loader": "^2.0.1",
|
|
19
16
|
"html-inline-css-webpack-plugin": "^1.11.2",
|
|
20
17
|
"html-inline-script-webpack-plugin": "^3.2.1",
|
|
21
18
|
"html-loader": "^5.0.0",
|
|
@@ -28,10 +25,12 @@
|
|
|
28
25
|
"null-loader": "^4.0.1",
|
|
29
26
|
"css-minimizer-webpack-plugin": "^6.0.0",
|
|
30
27
|
"postcss": "^8.4.33",
|
|
28
|
+
"postcss-discard-comments": "^6.0.2",
|
|
31
29
|
"postcss-import": "^16.0.0",
|
|
32
30
|
"postcss-import-webpack-resolver": "^1.0.1",
|
|
33
31
|
"postcss-loader": "^8.1.0",
|
|
34
32
|
"postcss-nested": "^6.0.1",
|
|
33
|
+
"postcss-normalize-whitespace": "^6.0.2",
|
|
35
34
|
"postcss-preset-env": "^9.3.0",
|
|
36
35
|
"postcss-scss": "^4.0.9",
|
|
37
36
|
"module-from-string": "^3.3.0",
|
|
@@ -50,7 +49,7 @@
|
|
|
50
49
|
"serve": "^14.2.1"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@enhanced-dom/lint": "
|
|
52
|
+
"@enhanced-dom/lint": "~0.1.4",
|
|
54
53
|
"@types/html-webpack-plugin": "^3.2.9",
|
|
55
54
|
"@types/loader-utils": "^2.0.6",
|
|
56
55
|
"@types/memory-fs": "^0.3.7",
|
|
@@ -1,27 +0,0 @@
|
|
|
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");
|
|
7
|
-
const cjs_1 = require("@enhanced-dom/css/cjs");
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
9
|
-
const loader = function () { };
|
|
10
|
-
loader.pitch = function pitch(remainingRequest) {
|
|
11
|
-
if (this.cacheable) {
|
|
12
|
-
this.cacheable();
|
|
13
|
-
}
|
|
14
|
-
const result = style_loader_1.default.pitch.call(this, remainingRequest);
|
|
15
|
-
const index = result.indexOf('var update = API(content, options)');
|
|
16
|
-
if (index <= -1)
|
|
17
|
-
return result;
|
|
18
|
-
const insertIndex = index - 1;
|
|
19
|
-
const stylesheetName = (0, lodash_1.uniqueId)('stylesheet');
|
|
20
|
-
const insertAttr = `
|
|
21
|
-
options.attributes = options.attributes || {}
|
|
22
|
-
options.attributes["${cjs_1.STYLESHEET_ATTRIBUTE_NAME}"] = "${stylesheetName}";
|
|
23
|
-
`;
|
|
24
|
-
return result.slice(0, insertIndex) + insertAttr + result.slice(insertIndex) + `export const _stylesheetName = "${stylesheetName}";`;
|
|
25
|
-
};
|
|
26
|
-
module.exports = loader;
|
|
27
|
-
//# sourceMappingURL=ExposeCssSourceLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;QACnB,IAAI,CAAC,SAAS,EAAE,CAAA;IAClB,CAAC;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"]}
|