@enhanced-dom/webpack 0.0.5 → 0.0.6

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.
@@ -0,0 +1,19 @@
1
+ import IgnoreEmitWebpackPlugin from 'ignore-emit-webpack-plugin';
2
+ export declare const typedStylesConfigFactory: ({ raw, filesPaths }: {
3
+ raw?: boolean;
4
+ filesPaths: string[];
5
+ }) => {
6
+ mode: string;
7
+ entry: {
8
+ bundle: string[];
9
+ };
10
+ devtool: boolean;
11
+ watch: boolean;
12
+ module: {
13
+ rules: {
14
+ test: RegExp;
15
+ use: any[];
16
+ }[];
17
+ };
18
+ plugins: IgnoreEmitWebpackPlugin[];
19
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.typedStylesConfigFactory = void 0;
7
+ const ignore_emit_webpack_plugin_1 = __importDefault(require("ignore-emit-webpack-plugin"));
8
+ const loaders_1 = require("../loaders");
9
+ const typedStylesConfigFactory = ({ raw, filesPaths }) => {
10
+ return {
11
+ mode: 'production',
12
+ entry: { bundle: filesPaths },
13
+ devtool: false,
14
+ watch: true,
15
+ module: {
16
+ rules: [
17
+ {
18
+ test: /\.(pcss|css)$/,
19
+ use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss', modules: true }),
20
+ },
21
+ {
22
+ test: /\.(scss|sass)$/,
23
+ use: (0, loaders_1.styleConfigFactory)({ raw, typedStyles: true, parser: 'postcss-scss', modules: true }),
24
+ },
25
+ ],
26
+ },
27
+ plugins: [new ignore_emit_webpack_plugin_1.default(/.+/)],
28
+ };
29
+ };
30
+ exports.typedStylesConfigFactory = typedStylesConfigFactory;
@@ -1,7 +1,9 @@
1
1
  import * as loaders from './loaders';
2
2
  import * as plugins from './plugins';
3
+ import * as configs from './configs';
3
4
  declare const _default: {
4
5
  loaders: typeof loaders;
5
6
  plugins: typeof plugins;
7
+ configs: typeof configs;
6
8
  };
7
9
  export = _default;
@@ -24,7 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  const loaders = __importStar(require("./loaders"));
26
26
  const plugins = __importStar(require("./plugins"));
27
+ const configs = __importStar(require("./configs"));
27
28
  module.exports = {
28
29
  loaders,
29
30
  plugins,
31
+ configs,
30
32
  };
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  const style_loader_1 = __importDefault(require("style-loader"));
6
6
  const lodash_1 = require("lodash");
7
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
7
8
  const loader = function () { };
8
9
  loader.pitch = function pitch(remainingRequest) {
9
10
  if (this.cacheable) {
@@ -4,12 +4,15 @@ export declare const styleConfigFactory: ({ raw, extract, sourceMap, typedStyles
4
4
  sourceMap?: boolean;
5
5
  typedStyles?: boolean;
6
6
  modules?: {
7
- localIdentName: string;
8
- mappings: {
7
+ localIdentName?: string;
8
+ mappings?: {
9
9
  filter: string;
10
10
  transform: (p: string) => string;
11
11
  }[];
12
- };
12
+ } | (boolean & {
13
+ localIdentName?: never;
14
+ mappings?: never;
15
+ });
13
16
  parser?: "postcss" | "postcss-scss";
14
17
  aliases?: Record<string, string>;
15
18
  }) => any[];
package/loaders/index.js CHANGED
@@ -6,6 +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
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9
10
  const ExposeCssSourceLoader = require.resolve('./ExposeCssSourceLoader');
10
11
  const remark_code_import_1 = __importDefault(require("remark-code-import"));
11
12
  const remark_unwrap_images_1 = __importDefault(require("remark-unwrap-images"));
@@ -51,8 +52,9 @@ const styleConfigFactory = ({ raw = false, extract = false, sourceMap = false, t
51
52
  modules: {
52
53
  localIdentName: (_a = modules === null || modules === void 0 ? void 0 : modules.localIdentName) !== null && _a !== void 0 ? _a : '[local]_[hash:base64:5]',
53
54
  getLocalIdent: (loaderContext, _, localName) => {
55
+ var _a;
54
56
  const { resourcePath } = loaderContext;
55
- const { mappings = [] } = modules !== null && modules !== void 0 ? modules : {};
57
+ const mappings = (_a = modules === null || modules === void 0 ? void 0 : modules.mappings) !== null && _a !== void 0 ? _a : [];
56
58
  const mapping = mappings.find(({ filter }) => resourcePath.includes(filter));
57
59
  if (!mapping) {
58
60
  return undefined; // this will trigger the default css-loader getLocalIdent function
package/package.json CHANGED
@@ -1,80 +1,78 @@
1
- {
2
- "name": "@enhanced-dom/webpack",
3
- "version": "0.0.5",
4
- "description": "Helpers for webpack configuration",
5
- "keywords": [],
6
- "repository": "https://github.com/enhanced-dom/webpack.git",
7
- "license": "MIT",
8
- "author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
9
- "main": "config.js",
10
- "scripts": {
11
- "prebuild": "rimraf dist/*",
12
- "build": "tsc -p ./tsconfig.json",
13
- "postbuild": "copyfiles package.json LICENSE.md README.md dist",
14
- "package": "cd dist && npm pack",
15
- "lint": "eslint src/** --fix --config eslint.config.js"
16
- },
17
- "dependencies": {
18
- "@mdx-js/loader": "^1.6.22",
19
- "autoprefixer": "^10.3.5",
20
- "babel-loader": "^8.2.2",
21
- "copyfiles": "^2.4.1",
22
- "css-loader": "^6.2.0",
23
- "cssnano-preset-advanced": "^5.1.3",
24
- "dts-css-modules-loader": "^1.2.3",
25
- "html-inline-css-webpack-plugin": "^1.11.1",
26
- "html-inline-script-webpack-plugin": "^2.0.3",
27
- "html-loader": "^2.1.2",
28
- "html-webpack-inline-source-plugin": "^0.0.10",
29
- "html-webpack-plugin": "^5.3.1",
30
- "markdown-loader": "^6.0.0",
31
- "mini-css-extract-plugin": "^2.3.0",
32
- "null-loader": "^4.0.1",
33
- "css-minimizer-webpack-plugin": "^3.0.2",
34
- "postcss": "^8.2.15",
35
- "postcss-import": "^14.0.2",
36
- "postcss-import-webpack-resolver": "^1.0.1",
37
- "postcss-loader": "^6.1.1",
38
- "postcss-nested": "^5.0.6",
39
- "postcss-preset-env": "^6.7.0",
40
- "postcss-advanced-variables": "^3.0.1",
41
- "postcss-scss": "^4.0.0",
42
- "module-from-string": "^3.0.0",
43
- "raw-loader": "^4.0.2",
44
- "remark-code-import": "^0.3.0",
45
- "remark-embed-images": "^2.0.0",
46
- "remark-images": "^2.0.0",
47
- "remark-unwrap-images": "^2.0.0",
48
- "resolve-url-loader": "^4.0.0",
49
- "rimraf": "^3.0.2",
50
- "source-map-loader": "^3.0.0",
51
- "style-loader": "^3.2.1",
52
- "terser-webpack-plugin": "^5.1.2",
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
- "serve": "^12.0.0"
58
- },
59
- "devDependencies": {
60
- "@enhanced-dom/lint": "^0.0.3",
61
- "@types/html-webpack-plugin": "^3.2.5",
62
- "@types/loader-utils": "^2.0.2",
63
- "@types/mini-css-extract-plugin": "^1.4.3",
64
- "@types/optimize-css-assets-webpack-plugin": "^5.0.3",
65
- "@types/terser-webpack-plugin": "^5.2.0",
66
- "@types/webpack": "^5.28.0",
67
- "@types/webpack-bundle-analyzer": "^2.9.2",
68
- "typescript": "^4.2.2"
69
- },
70
- "overrides": {
71
- "postcss": "^8.2.15",
72
- "postcss-scss": "^4.0.0",
73
- "autoprefixer": "^10.3.5",
74
- "terser": "^5.12.1"
75
- },
76
- "engines": {
77
- "node": ">=14.17.0",
78
- "npm": ">=8.0.0"
79
- }
80
- }
1
+ {
2
+ "name": "@enhanced-dom/webpack",
3
+ "version": "0.0.6",
4
+ "description": "Helpers for webpack configuration",
5
+ "keywords": [],
6
+ "repository": "https://github.com/enhanced-dom/webpack.git",
7
+ "license": "MIT",
8
+ "author": "CD9B4A105290E17E0948E021DF4105107C88693C59C0B891CCC08366C51AEA990902A6A156AC87D88A2FC41422A5E1C3C4071F251F19441C4516000EC25F87DF",
9
+ "main": "index.js",
10
+ "bin": {
11
+ "@enhanced-dom-copy-packagejson": "./scripts/copyPackageJson.js"
12
+ },
13
+ "dependencies": {
14
+ "@mdx-js/loader": "^1.6.22",
15
+ "autoprefixer": "^10.3.5",
16
+ "babel-loader": "^8.2.2",
17
+ "copyfiles": "^2.4.1",
18
+ "css-loader": "^6.2.0",
19
+ "cssnano-preset-advanced": "^5.1.3",
20
+ "dts-css-modules-loader": "^1.2.3",
21
+ "html-inline-css-webpack-plugin": "^1.11.1",
22
+ "html-inline-script-webpack-plugin": "^2.0.3",
23
+ "html-loader": "^2.1.2",
24
+ "html-webpack-inline-source-plugin": "^0.0.10",
25
+ "html-webpack-plugin": "^5.3.1",
26
+ "ignore-emit-webpack-plugin": "^2.0.6",
27
+ "markdown-loader": "^6.0.0",
28
+ "mini-css-extract-plugin": "^2.3.0",
29
+ "null-loader": "^4.0.1",
30
+ "css-minimizer-webpack-plugin": "^3.0.2",
31
+ "postcss": "^8.2.15",
32
+ "postcss-import": "^14.0.2",
33
+ "postcss-import-webpack-resolver": "^1.0.1",
34
+ "postcss-loader": "^6.1.1",
35
+ "postcss-nested": "^5.0.6",
36
+ "postcss-preset-env": "^6.7.0",
37
+ "postcss-advanced-variables": "^3.0.1",
38
+ "postcss-scss": "^4.0.0",
39
+ "module-from-string": "^3.0.0",
40
+ "raw-loader": "^4.0.2",
41
+ "remark-code-import": "^0.3.0",
42
+ "remark-embed-images": "^2.0.0",
43
+ "remark-images": "^2.0.0",
44
+ "remark-unwrap-images": "^2.0.0",
45
+ "resolve-url-loader": "^4.0.0",
46
+ "rimraf": "^3.0.2",
47
+ "source-map-loader": "^3.0.0",
48
+ "style-loader": "^3.2.1",
49
+ "terser-webpack-plugin": "^5.1.2",
50
+ "webpack": "^5.70.0",
51
+ "webpack-bundle-analyzer": "^4.5.0",
52
+ "webpack-cli": "^4.9.2",
53
+ "webpack-dev-server": "^4.7.4",
54
+ "serve": "^12.0.0",
55
+ "yargs": "^17.4.1"
56
+ },
57
+ "devDependencies": {
58
+ "@enhanced-dom/lint": "^0.0.6",
59
+ "@types/html-webpack-plugin": "^3.2.5",
60
+ "@types/loader-utils": "^2.0.2",
61
+ "@types/mini-css-extract-plugin": "^1.4.3",
62
+ "@types/optimize-css-assets-webpack-plugin": "^5.0.3",
63
+ "@types/terser-webpack-plugin": "^5.2.0",
64
+ "@types/webpack": "^5.28.0",
65
+ "@types/webpack-bundle-analyzer": "^2.9.2",
66
+ "typescript": "^4.2.2"
67
+ },
68
+ "overrides": {
69
+ "postcss": "^8.2.15",
70
+ "postcss-scss": "^4.0.0",
71
+ "autoprefixer": "^10.3.5",
72
+ "terser": "^5.12.1"
73
+ },
74
+ "engines": {
75
+ "node": ">=14.17.0",
76
+ "npm": ">=8.0.0"
77
+ }
78
+ }
@@ -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
+ /* eslint-disable @typescript-eslint/no-this-alias */
5
6
  const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
6
7
  const html_webpack_inline_source_plugin_1 = __importDefault(require("html-webpack-inline-source-plugin"));
7
8
  const fs_1 = __importDefault(require("fs"));
package/plugins/index.js CHANGED
@@ -69,6 +69,7 @@ const htmlConfigFactory = ({ html = {}, embed } = {}) => {
69
69
  };
70
70
  exports.htmlConfigFactory = htmlConfigFactory;
71
71
  const terserConfigFactory = ({ enableSourcemaps = true, terserOptions = {} } = {}) => [
72
+ /* eslint-disable @typescript-eslint/naming-convention */
72
73
  new terser_webpack_plugin_1.default({
73
74
  parallel: true,
74
75
  terserOptions: {
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+ const yargs = require('yargs')
6
+ const args = yargs(process.argv).usage("$0 <folder>").positional('folder', { describe: 'destination folder for package.json copy', type: 'string' }).default('folder', 'dist').argv
7
+ const packageJSONContents = require(path.join(process.cwd(), 'package.json'))
8
+ delete packageJSONContents.scripts
9
+ fs.writeFileSync(path.join(process.cwd(), args.folder, 'package.json'), JSON.stringify(packageJSONContents, null, 2))