@enhanced-dom/webpack 0.0.12 → 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.
@@ -1,11 +1,11 @@
1
- import webpack from 'webpack';
1
+ import { type Compiler, type Configuration } from 'webpack';
2
2
  import MemoryFS from 'memory-fs';
3
- export declare const proxyFilesystem: (originalFilesystem: webpack.Compiler['inputFileSystem']) => MemoryFS;
4
- export declare const patchCompilerFileSystem: (originalCompiler: webpack.Compiler, allowProxy?: boolean) => Omit<webpack.Compiler, "inputFileSystem" | "outputFileSystem"> & {
3
+ export declare const proxyFilesystem: (originalFilesystem: Compiler['inputFileSystem']) => MemoryFS;
4
+ export declare const patchCompilerFileSystem: (originalCompiler: Compiler, allowProxy?: boolean) => Omit<Compiler, "inputFileSystem" | "outputFileSystem"> & {
5
5
  inputFileSystem: MemoryFS;
6
6
  outputFileSystem: MemoryFS;
7
7
  };
8
- export declare const getInMemoryCompiler: (webpackConfig: webpack.Configuration, allowProxy?: boolean) => Omit<webpack.Compiler, "inputFileSystem" | "outputFileSystem"> & {
8
+ export declare const getInMemoryCompiler: (webpackConfig: Configuration, allowProxy?: boolean) => Omit<Compiler, "inputFileSystem" | "outputFileSystem"> & {
9
9
  inputFileSystem: MemoryFS;
10
10
  outputFileSystem: MemoryFS;
11
11
  };
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getInMemoryCompiler = exports.patchCompilerFileSystem = exports.proxyFilesystem = void 0;
7
- const webpack_1 = __importDefault(require("webpack"));
7
+ const webpack_1 = require("webpack");
8
8
  const memory_fs_1 = __importDefault(require("memory-fs"));
9
9
  const proxyFilesystem = (originalFilesystem) => {
10
10
  // Inspired by: https://stackoverflow.com/questions/38779924/compiling-webpack-in-memory-but-resolving-to-node-modules-on-disk
@@ -37,7 +37,7 @@ const patchCompilerFileSystem = (originalCompiler, allowProxy = true) => {
37
37
  };
38
38
  exports.patchCompilerFileSystem = patchCompilerFileSystem;
39
39
  const getInMemoryCompiler = (webpackConfig, allowProxy = true) => {
40
- return (0, exports.patchCompilerFileSystem)((0, webpack_1.default)(webpackConfig), allowProxy);
40
+ return (0, exports.patchCompilerFileSystem)((0, webpack_1.webpack)(webpackConfig), allowProxy);
41
41
  };
42
42
  exports.getInMemoryCompiler = getInMemoryCompiler;
43
43
  //# sourceMappingURL=compiler.helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.helpers.js","sourceRoot":"./","sources":["compiler.helpers.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,0DAAgC;AAEzB,MAAM,eAAe,GAAG,CAAC,kBAAuD,EAAE,EAAE;IACzF,8HAA8H;IAC9H,MAAM,KAAK,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvC,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/C,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAC5B,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,GAAG,EAAE;gBACP,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;aAC7C;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,KAAK,CAAC,QAAQ,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAChC,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YACjD,IAAI,GAAG,EAAE;gBACP,OAAO,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;aACjD;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAvBY,QAAA,eAAe,mBAuB3B;AAEM,MAAM,uBAAuB,GAAG,CAAC,gBAAkC,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IAC/F,gBAAgB,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,IAAA,uBAAe,EAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAQ,EAAE,CAAA;IAClH,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAElD,OAAO,gBAGN,CAAA;AACH,CAAC,CAAA;AARY,QAAA,uBAAuB,2BAQnC;AAEM,MAAM,mBAAmB,GAAG,CAAC,aAAoC,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IAC7F,OAAO,IAAA,+BAAuB,EAAC,IAAA,iBAAO,EAAC,aAAa,CAAC,EAAE,UAAU,CAAC,CAAA;AACpE,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B","sourcesContent":["import webpack from 'webpack'\nimport MemoryFS from 'memory-fs'\n\nexport const proxyFilesystem = (originalFilesystem: webpack.Compiler['inputFileSystem']) => {\n // Inspired by: https://stackoverflow.com/questions/38779924/compiling-webpack-in-memory-but-resolving-to-node-modules-on-disk\n const memFs = new MemoryFS()\n const statOrig = memFs.stat.bind(memFs)\n const readFileOrig = memFs.readFile.bind(memFs)\n memFs.stat = (filePath, cb) => {\n statOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.stat(filePath, cb)\n }\n return cb(err, result)\n })\n }\n memFs.readFile = (filePath, cb) => {\n readFileOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.readFile(filePath, cb)\n }\n return cb(err, result)\n })\n }\n\n return memFs\n}\n\nexport const patchCompilerFileSystem = (originalCompiler: webpack.Compiler, allowProxy = true) => {\n originalCompiler.inputFileSystem = allowProxy ? proxyFilesystem(originalCompiler.inputFileSystem) : new MemoryFS()\n originalCompiler.outputFileSystem = new MemoryFS()\n\n return originalCompiler as Omit<webpack.Compiler, 'inputFileSystem' | 'outputFileSystem'> & {\n inputFileSystem: MemoryFS\n outputFileSystem: MemoryFS\n }\n}\n\nexport const getInMemoryCompiler = (webpackConfig: webpack.Configuration, allowProxy = true) => {\n return patchCompilerFileSystem(webpack(webpackConfig), allowProxy)\n}\n"]}
1
+ {"version":3,"file":"compiler.helpers.js","sourceRoot":"./","sources":["compiler.helpers.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAoE;AACpE,0DAAgC;AAEzB,MAAM,eAAe,GAAG,CAAC,kBAA+C,EAAE,EAAE;IACjF,8HAA8H;IAC9H,MAAM,KAAK,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvC,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/C,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAC5B,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YAC9C,CAAC;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,KAAK,CAAC,QAAQ,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QAChC,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,MAAW,EAAE,EAAE;YACjD,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YAClD,CAAC;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAvBY,QAAA,eAAe,mBAuB3B;AAEM,MAAM,uBAAuB,GAAG,CAAC,gBAA0B,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IACvF,gBAAgB,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,IAAA,uBAAe,EAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAQ,EAAE,CAAA;IAClH,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,mBAAQ,EAAE,CAAA;IAElD,OAAO,gBAGN,CAAA;AACH,CAAC,CAAA;AARY,QAAA,uBAAuB,2BAQnC;AAEM,MAAM,mBAAmB,GAAG,CAAC,aAA4B,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE;IACrF,OAAO,IAAA,+BAAuB,EAAC,IAAA,iBAAO,EAAC,aAAa,CAAC,EAAE,UAAU,CAAC,CAAA;AACpE,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B","sourcesContent":["import { type Compiler, type Configuration, webpack } from 'webpack'\nimport MemoryFS from 'memory-fs'\n\nexport const proxyFilesystem = (originalFilesystem: Compiler['inputFileSystem']) => {\n // Inspired by: https://stackoverflow.com/questions/38779924/compiling-webpack-in-memory-but-resolving-to-node-modules-on-disk\n const memFs = new MemoryFS()\n const statOrig = memFs.stat.bind(memFs)\n const readFileOrig = memFs.readFile.bind(memFs)\n memFs.stat = (filePath, cb) => {\n statOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.stat(filePath, cb)\n }\n return cb(err, result)\n })\n }\n memFs.readFile = (filePath, cb) => {\n readFileOrig(filePath, (err: Error, result: any) => {\n if (err) {\n return originalFilesystem.readFile(filePath, cb)\n }\n return cb(err, result)\n })\n }\n\n return memFs\n}\n\nexport const patchCompilerFileSystem = (originalCompiler: Compiler, allowProxy = true) => {\n originalCompiler.inputFileSystem = allowProxy ? proxyFilesystem(originalCompiler.inputFileSystem) : new MemoryFS()\n originalCompiler.outputFileSystem = new MemoryFS()\n\n return originalCompiler as Omit<Compiler, 'inputFileSystem' | 'outputFileSystem'> & {\n inputFileSystem: MemoryFS\n outputFileSystem: MemoryFS\n }\n}\n\nexport const getInMemoryCompiler = (webpackConfig: Configuration, allowProxy = true) => {\n return patchCompilerFileSystem(webpack(webpackConfig), allowProxy)\n}\n"]}
@@ -1,14 +1,17 @@
1
1
  import IgnoreEmitWebpackPlugin from 'ignore-emit-webpack-plugin';
2
- export declare const typedStylesConfigFactory: ({ raw, filesPaths }: {
2
+ export declare const typedStylesConfigFactory: ({ raw, filePaths, outputPath }: {
3
3
  raw?: boolean;
4
- filesPaths: string[];
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
- watch: boolean;
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, filesPaths }) => {
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: 'production',
12
- entry: { bundle: filesPaths },
13
+ mode: 'development',
14
+ entry: { bundle: filePaths },
13
15
  devtool: false,
14
- watch: true,
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', modules: true }),
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', modules: true }),
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;
@@ -1 +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"]}
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,5 @@
1
+ declare const loader: {
2
+ (content: string): string;
3
+ pitch(request: string): Promise<void>;
4
+ };
5
+ export = loader;
@@ -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;;I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AAG,KAAK,GAAG,OAAO,CAAC,CAAA;IACzG,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAA;IAC1D,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAA;IACnD,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAClC,CAAC,CAAC,UAAU,EAAE,WAAW,CAAmB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,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 ExposeCssSourceLoader = require.resolve('./ExposeCssSourceLoader');
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: ExposeCssSourceLoader,
18
+ loader: WebcomponentStyleLoader,
19
19
  options: {
20
- attributes: {},
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
- loaders.push({ loader: 'style-loader' });
34
- }
35
- if (typedStyles) {
36
- loaders.push({
37
- loader: 'dts-css-modules-loader',
38
- options: {
39
- namedExport: true,
40
- banner: raw ? 'export const _stylesheetName: string;' : undefined,
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
  {
@@ -89,12 +96,14 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
89
96
  modules: ['./node_modules', 'node_modules'],
90
97
  },
91
98
  ],
92
- 'postcss-advanced-variables',
93
99
  'postcss-nested',
94
- 'autoprefixer',
95
- // ['postcss-preset-env', {
96
- // browsers: ['last 2 versions']
97
- // }]
100
+ // 'autoprefixer',
101
+ [
102
+ 'postcss-preset-env',
103
+ {
104
+ stage: 3,
105
+ },
106
+ ],
98
107
  ],
99
108
  },
100
109
  },
@@ -1 +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;QACP,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,qBAAqB;YAC7B,OAAO,EAAE;gBACP,UAAU,EAAE,EAAE;aACf;SACF,CAAC,CAAA;KACH;SAAM,IAAI,OAAO,EAAE;QAClB,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,iCAAoB,CAAC,MAAM;YACnC,OAAO,EAAE;gBACP,UAAU,EAAE,IAAI;aACjB;SACF,CAAC,CAAA;KACH;SAAM;QACL,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAA;KACzC;IAED,IAAI,WAAW,EAAE;QACf,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,wBAAwB;YAChC,OAAO,EAAE;gBACP,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC,CAAC,SAAS;aAClE;SACF,CAAC,CAAA;KACH;IAED,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE;YACP,SAAS;YACT,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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;QACT,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;KACH;SAAM;QACL,OAAO,CAAC,IAAI,CACV;YACE,MAAM,EAAE,aAAa;SACtB,EACD;YACE,MAAM,EAAE,iBAAiB;SAC1B,CACF,CAAA;KACF;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 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 = ({\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"]}
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,CAA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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.0.12",
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,69 +8,59 @@
8
8
  "author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
9
9
  "main": "index.js",
10
10
  "dependencies": {
11
- "@enhanced-dom/build": "^0.0.2",
12
- "@enhanced-dom/css": "^0.0.3",
13
- "@mdx-js/loader": "^2.1.1",
14
- "autoprefixer": "^10.3.5",
15
- "babel-loader": "^8.2.2",
16
- "css-loader": "^6.2.0",
17
- "cssnano-preset-advanced": "^5.1.3",
18
- "dts-css-modules-loader": "^1.2.3",
19
- "html-inline-css-webpack-plugin": "^1.11.1",
20
- "html-inline-script-webpack-plugin": "^2.0.3",
21
- "html-loader": "^2.1.2",
11
+ "@enhanced-dom/build": "~0.1.0",
12
+ "@mdx-js/loader": "^3.0.0",
13
+ "babel-loader": "^9.1.3",
14
+ "css-loader": "^6.10.0",
15
+ "cssnano-preset-advanced": "^6.0.3",
16
+ "html-inline-css-webpack-plugin": "^1.11.2",
17
+ "html-inline-script-webpack-plugin": "^3.2.1",
18
+ "html-loader": "^5.0.0",
22
19
  "html-webpack-inline-source-plugin": "^0.0.10",
23
- "html-webpack-plugin": "^5.3.1",
20
+ "html-webpack-plugin": "^5.6.0",
24
21
  "ignore-emit-webpack-plugin": "^2.0.6",
25
22
  "markdown-loader": "^8.0.0",
26
23
  "memory-fs": "^0.5.0",
27
- "mini-css-extract-plugin": "^2.3.0",
24
+ "mini-css-extract-plugin": "^2.8.0",
28
25
  "null-loader": "^4.0.1",
29
- "css-minimizer-webpack-plugin": "^3.0.2",
30
- "postcss": "^8.2.15",
31
- "postcss-import": "^14.0.2",
26
+ "css-minimizer-webpack-plugin": "^6.0.0",
27
+ "postcss": "^8.4.33",
28
+ "postcss-discard-comments": "^6.0.2",
29
+ "postcss-import": "^16.0.0",
32
30
  "postcss-import-webpack-resolver": "^1.0.1",
33
- "postcss-loader": "^6.1.1",
34
- "postcss-nested": "^5.0.6",
35
- "postcss-preset-env": "^6.7.0",
36
- "postcss-advanced-variables": "^3.0.1",
37
- "postcss-scss": "^4.0.0",
38
- "module-from-string": "^3.0.0",
31
+ "postcss-loader": "^8.1.0",
32
+ "postcss-nested": "^6.0.1",
33
+ "postcss-normalize-whitespace": "^6.0.2",
34
+ "postcss-preset-env": "^9.3.0",
35
+ "postcss-scss": "^4.0.9",
36
+ "module-from-string": "^3.3.0",
39
37
  "raw-loader": "^4.0.2",
40
38
  "remark-code-import": "^0.3.0",
41
39
  "remark-embed-images": "^2.0.0",
42
- "remark-images": "^2.0.0",
43
- "remark-unwrap-images": "^2.0.0",
44
- "resolve-url-loader": "^4.0.0",
45
- "source-map-loader": "^3.0.0",
46
- "style-loader": "^3.2.1",
47
- "terser-webpack-plugin": "^5.1.2",
48
- "webpack": "^5.70.0",
49
- "webpack-bundle-analyzer": "^4.5.0",
50
- "webpack-cli": "^4.9.2",
51
- "webpack-dev-server": "^4.9.0",
52
- "serve": "^14.1.2"
40
+ "remark-unwrap-images": "^2.1.0",
41
+ "resolve-url-loader": "^5.0.0",
42
+ "source-map-loader": "^5.0.0",
43
+ "style-loader": "^3.3.4",
44
+ "terser-webpack-plugin": "^5.3.10",
45
+ "webpack": "^5.90.1",
46
+ "webpack-bundle-analyzer": "^4.10.1",
47
+ "webpack-cli": "^5.1.4",
48
+ "webpack-dev-server": "^4.15.1",
49
+ "serve": "^14.2.1"
53
50
  },
54
51
  "devDependencies": {
55
- "@enhanced-dom/lint": "^0.0.9",
56
- "@types/html-webpack-plugin": "^3.2.5",
57
- "@types/loader-utils": "^2.0.2",
58
- "@types/memory-fs": "^0.3.3",
59
- "@types/mini-css-extract-plugin": "^1.4.3",
60
- "@types/optimize-css-assets-webpack-plugin": "^5.0.3",
52
+ "@enhanced-dom/lint": "~0.1.4",
53
+ "@types/html-webpack-plugin": "^3.2.9",
54
+ "@types/loader-utils": "^2.0.6",
55
+ "@types/memory-fs": "^0.3.7",
56
+ "@types/optimize-css-assets-webpack-plugin": "^5.0.8",
61
57
  "@types/terser-webpack-plugin": "^5.2.0",
62
- "@types/webpack": "^5.28.0",
63
- "@types/webpack-bundle-analyzer": "^2.9.2",
64
- "typescript": "^4.9.4"
65
- },
66
- "overrides": {
67
- "postcss": "^8.2.15",
68
- "postcss-scss": "^4.0.0",
69
- "autoprefixer": "^10.3.5",
70
- "terser": "^5.12.1"
58
+ "@types/webpack": "^5.28.5",
59
+ "@types/webpack-bundle-analyzer": "^4.6.3",
60
+ "typescript": "^5.3.3"
71
61
  },
72
62
  "engines": {
73
- "node": ">=14.17.0",
74
- "npm": ">=8.0.0"
63
+ "node": ">=18",
64
+ "npm": ">=10"
75
65
  }
76
66
  }
@@ -1,2 +1,2 @@
1
1
  import HtmlWebpackInlineSourcePlugin from 'html-webpack-inline-source-plugin';
2
- export = HtmlWebpackInlineSourcePlugin;
2
+ export default HtmlWebpackInlineSourcePlugin;
@@ -2,6 +2,7 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
5
6
  /* eslint-disable @typescript-eslint/no-this-alias */
6
7
  const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
7
8
  const html_webpack_inline_source_plugin_1 = __importDefault(require("html-webpack-inline-source-plugin"));
@@ -50,5 +51,5 @@ html_webpack_inline_source_plugin_1.default.prototype.apply = function (compiler
50
51
  }
51
52
  });
52
53
  };
53
- module.exports = html_webpack_inline_source_plugin_1.default;
54
+ exports.default = html_webpack_inline_source_plugin_1.default;
54
55
  //# sourceMappingURL=HtmlWebpackInlineSourcePlugin.js.map
@@ -1 +1 @@
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AC,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"]}
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,UAA6E;IAE7E,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,2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AC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,mCAAmC,EAAE,CAAC,WAAW,EAAE,EAAE;QAC3E,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,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,CAAC;oBACvF,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;gBACjC,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,kBAAe,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 { type Compilation, type Compiler } from 'webpack'\nimport { AsyncSeriesWaterfallHook } from 'tapable'\nimport fs from 'fs'\nimport path from 'path'\n\ntype AsyncSeriesWaterfallHookDataType<T> = T extends AsyncSeriesWaterfallHook<infer R> ? R : never\n\nHtmlWebpackInlineSourcePlugin.prototype.processTags = function (\n compilation: Compilation,\n pluginData: AsyncSeriesWaterfallHookDataType<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 default HtmlWebpackInlineSourcePlugin\n"]}
@@ -4,7 +4,7 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
4
4
  import TerserPlugin from 'terser-webpack-plugin';
5
5
  import { MinifyOptions } from 'terser';
6
6
  import HtmlWebpackPlugin from 'html-webpack-plugin';
7
- import { WebpackPluginInstance } from 'webpack';
7
+ import { type WebpackPluginInstance } from 'webpack';
8
8
  export declare const cssConfigFactory: ({ filename, cssnanoOptions, }?: {
9
9
  filename?: string;
10
10
  cssnanoOptions?: any;
@@ -1 +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,8EAAm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,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAClI,MAAM,OAAO,GAA4B;QACvC,IAAI,6BAAiB,CAAC;YACpB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,OAAO;YACb,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC;YACxD,GAAG,IAAI;YACP,OAAO;SACR,CAAC;KACH,CAAA;IAED,IAAI,KAAK,EAAE;QACT,OAAO,CAAC,IAAI,CAAC,IAAI,uCAAsB,EAAE,CAAC,CAAA;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,EAAE,KAAK,GAAG,KAAK,KAAK,EAAE,EAAE,EAAE,CAAC;IAC3H,yDAAyD;IACzD,IAAI,+BAAY,CAAC;QACf,QAAQ,EAAE,IAAI;QACd,eAAe,EAAE,CAAC,KAAK;QACvB,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;AApBY,QAAA,mBAAmB,uBAoB/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, embed = false } = {}) => [\n /* eslint-disable @typescript-eslint/naming-convention */\n new TerserPlugin({\n parallel: true,\n extractComments: !embed,\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"]}
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,gBAAgB,oBAiB5B;AAEM,MAAM,2BAA2B,GAAG,CAAC,cAA4C,EAAE,EAAE,EAAE;IAC5F,OAAO;QACL,IAAI,8CAAoB,CAAC;YACvB,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,gCAAgC;YAChD,YAAY,EAAE,KAAK;YACnB,GAAG,WAAW;SACf,CAAC;KACH,CAAA;AACH,CAAC,CAAA;AATY,QAAA,2BAA2B,+BASvC;AAEM,MAAM,iBAAiB,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,KAAqE,EAAE,EAAE,EAAE;;IAC7H,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,QAAQ,mCAAI,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAA;IAC3E,MAAM,cAAc,GAAG,YAAE,CAAC,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,eAAe,EAAE,IAAI;aACtB;YACD,GAAG,aAAa;SACjB;KACF,CAAC;CACH,CAAA;AApBY,QAAA,mBAAmB,uBAoB/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 { type 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, embed = false } = {}) => [\n /* eslint-disable @typescript-eslint/naming-convention */\n new TerserPlugin({\n parallel: true,\n extractComments: !embed,\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"]}
@@ -1,5 +0,0 @@
1
- declare const loader: {
2
- (): void;
3
- pitch(remainingRequest: string): string;
4
- };
5
- export = loader;
@@ -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;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"]}