@rushstack/heft-web-rig 0.8.2 → 0.9.2

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/README.md CHANGED
@@ -4,7 +4,11 @@ A rig package for web projects that build using [Heft](https://www.npmjs.com/pac
4
4
  build system. To learn more about rig packages, consult the
5
5
  [@rushstack/rig-package](https://www.npmjs.com/package/@rushstack/rig-package) documentation.
6
6
 
7
- This rig contains a single profile: `library`
7
+ This rig provides the following profiles:
8
+
9
+ - [app](./profiles/app/): For applications that get bundled using Webpack.
10
+ - [library](./profiles/library/): For creating library packages to be consumed by other web projects. ***Also use this profile for a library meant to be used by both Node.js and web apps.***
11
+
8
12
 
9
13
  To enable it, add a **rig.json** file to your project, as shown below:
10
14
 
package/package.json CHANGED
@@ -1,30 +1,47 @@
1
1
  {
2
- "name": "@rushstack/heft-web-rig",
3
- "version": "0.8.2",
4
- "description": "A rig package for web browser projects that build using Heft",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/microsoft/rushstack.git",
9
- "directory": "rigs/heft-web-rig"
10
- },
11
- "peerDependencies": {
12
- "@rushstack/heft": "^0.44.2"
13
- },
14
- "dependencies": {
15
- "@microsoft/api-extractor": "7.19.4",
16
- "@rushstack/heft-jest-plugin": "0.2.2",
17
- "@rushstack/heft-sass-plugin": "0.3.6",
18
- "@rushstack/heft-webpack4-plugin": "0.3.32",
19
- "eslint": "~8.7.0",
20
- "jest-environment-jsdom": "~27.4.2",
21
- "typescript": "~4.5.2"
22
- },
23
- "devDependencies": {
24
- "@rushstack/heft": "0.44.2"
25
- },
26
- "scripts": {
27
- "build": "",
28
- "_phase:build": ""
29
- }
30
- }
2
+ "name": "@rushstack/heft-web-rig",
3
+ "version": "0.9.2",
4
+ "description": "A rig package for web browser projects that build using Heft",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/microsoft/rushstack.git",
9
+ "directory": "rigs/heft-web-rig"
10
+ },
11
+ "peerDependencies": {
12
+ "@rushstack/heft": "^0.44.4"
13
+ },
14
+ "dependencies": {
15
+ "@microsoft/api-extractor": "7.19.5",
16
+ "@rushstack/heft-jest-plugin": "0.2.5",
17
+ "@rushstack/heft-sass-plugin": "0.3.9",
18
+ "@rushstack/heft-webpack5-plugin": "0.5.2",
19
+ "autoprefixer": "~10.4.2",
20
+ "css-loader": "~6.6.0",
21
+ "css-minimizer-webpack-plugin": "~3.4.1",
22
+ "eslint": "~8.7.0",
23
+ "html-webpack-plugin": "~5.5.0",
24
+ "jest-environment-jsdom": "~27.4.2",
25
+ "mini-css-extract-plugin": "~2.5.3",
26
+ "postcss-loader": "~6.2.1",
27
+ "postcss": "~8.4.6",
28
+ "sass-loader": "~12.4.0",
29
+ "sass": "~1.49.7",
30
+ "source-map-loader": "~3.0.1",
31
+ "style-loader": "~3.3.1",
32
+ "terser-webpack-plugin": "~5.3.1",
33
+ "typescript": "~4.5.5",
34
+ "url-loader": "~4.1.1",
35
+ "webpack-bundle-analyzer": "~4.5.0",
36
+ "webpack-merge": "~5.8.0",
37
+ "webpack": "~5.68.0"
38
+ },
39
+ "devDependencies": {
40
+ "@rushstack/heft": "0.44.4"
41
+ },
42
+ "scripts": {
43
+ "build": "",
44
+ "_phase:build": ""
45
+ },
46
+ "readme": "## @rushstack/heft-web-rig\n\nA rig package for web projects that build using [Heft](https://www.npmjs.com/package/@rushstack/heft)\nbuild system. To learn more about rig packages, consult the\n[@rushstack/rig-package](https://www.npmjs.com/package/@rushstack/rig-package) documentation.\n\nThis rig provides the following profiles:\n\n- [app](./profiles/app/): For applications that get bundled using Webpack.\n- [library](./profiles/library/): For creating library packages to be consumed by other web projects. ***Also use this profile for a library meant to be used by both Node.js and web apps.***\n\n\nTo enable it, add a **rig.json** file to your project, as shown below:\n\n**config/rig.json**\n```js\n{\n \"$schema\": \"https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json\",\n\n \"rigPackageName\": \"@rushstack/heft-web-rig\",\n \"rigProfile\": \"library\"\n}\n```\n\nThe config files provided by this rig profile can be found in the [heft-web-rig/profiles/library](\nhttps://github.com/microsoft/rushstack/tree/master/rigs/heft-web-rig/profiles/library) source folder.\n\n\n## Links\n\n- [CHANGELOG.md](\n https://github.com/microsoft/rushstack/blob/master/rigs/heft-web-rig/CHANGELOG.md) - Find\n out what's new in the latest version\n\n`@rushstack/heft-web-rig` is part of the [Rush Stack](https://rushstack.io/) family of projects.\n"
47
+ }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Defines configuration used by core Heft.
3
+ */
4
+ {
5
+ "$schema": "https://developer.microsoft.com/json-schemas/heft/heft.schema.json",
6
+
7
+ /**
8
+ * Optionally specifies another JSON config file that this file extends from. This provides a way for standard
9
+ * settings to be shared across multiple projects.
10
+ */
11
+ // "extends": "base-project/config/heft.json",
12
+
13
+ "eventActions": [
14
+ // {
15
+ // /**
16
+ // * (Required) The kind of built-in operation that should be performed.
17
+ // * The "deleteGlobs" action deletes files or folders that match the specified glob patterns.
18
+ // */
19
+ // "actionKind": "deleteGlobs",
20
+ //
21
+ // /**
22
+ // * (Required) The Heft stage when this action should be performed. Note that heft.json event actions
23
+ // * are scheduled after any plugin tasks have processed the event. For example, a "compile" event action
24
+ // * will be performed after the TypeScript compiler has been invoked.
25
+ // *
26
+ // * Options: "clean", "pre-compile", "compile", "bundle", "post-build"
27
+ // */
28
+ // "heftEvent": "clean",
29
+ //
30
+ // /**
31
+ // * (Required) A user-defined tag whose purpose is to allow configs to replace/delete handlers that
32
+ // * were added by other configs.
33
+ // */
34
+ // "actionId": "my-example-action",
35
+ //
36
+ // /**
37
+ // * (Required) Glob patterns to be deleted. The paths are resolved relative to the project folder.
38
+ // * Documentation for supported glob syntaxes: https://www.npmjs.com/package/fast-glob
39
+ // */
40
+ // "globsToDelete": [
41
+ // "dist",
42
+ // "lib",
43
+ // "lib-esnext",
44
+ // "temp"
45
+ // ]
46
+ // },
47
+ //
48
+ // {
49
+ // /**
50
+ // * (Required) The kind of built-in operation that should be performed.
51
+ // * The "copyFiles" action copies files that match the specified patterns.
52
+ // */
53
+ // "actionKind": "copyFiles",
54
+ //
55
+ // /**
56
+ // * (Required) The Heft stage when this action should be performed. Note that heft.json event actions
57
+ // * are scheduled after any plugin tasks have processed the event. For example, a "compile" event action
58
+ // * will be performed after the TypeScript compiler has been invoked.
59
+ // *
60
+ // * Options: "pre-compile", "compile", "bundle", "post-build"
61
+ // */
62
+ // "heftEvent": "pre-compile",
63
+ //
64
+ // /**
65
+ // * (Required) A user-defined tag whose purpose is to allow configs to replace/delete handlers that
66
+ // * were added by other configs.
67
+ // */
68
+ // "actionId": "my-example-action",
69
+ //
70
+ // /**
71
+ // * (Required) An array of copy operations to run perform during the specified Heft event.
72
+ // */
73
+ // "copyOperations": [
74
+ // {
75
+ // /**
76
+ // * (Required) The base folder that files will be copied from, relative to the project root.
77
+ // * Settings such as "includeGlobs" and "excludeGlobs" will be resolved relative
78
+ // * to this folder.
79
+ // * NOTE: Assigning "sourceFolder" does not by itself select any files to be copied.
80
+ // */
81
+ // "sourceFolder": "src",
82
+ //
83
+ // /**
84
+ // * (Required) One or more folders that files will be copied into, relative to the project root.
85
+ // * If you specify more than one destination folder, Heft will read the input files only once, using
86
+ // * streams to efficiently write multiple outputs.
87
+ // */
88
+ // "destinationFolders": ["dist/assets"],
89
+ //
90
+ // /**
91
+ // * If specified, this option recursively scans all folders under "sourceFolder" and includes any files
92
+ // * that match the specified extensions. (If "fileExtensions" and "includeGlobs" are both
93
+ // * specified, their selections are added together.)
94
+ // */
95
+ // "fileExtensions": [".jpg", ".png"],
96
+ //
97
+ // /**
98
+ // * A list of glob patterns that select files to be copied. The paths are resolved relative
99
+ // * to "sourceFolder".
100
+ // * Documentation for supported glob syntaxes: https://www.npmjs.com/package/fast-glob
101
+ // */
102
+ // "includeGlobs": ["assets/*.md"],
103
+ //
104
+ // /**
105
+ // * A list of glob patterns that exclude files/folders from being copied. The paths are resolved relative
106
+ // * to "sourceFolder". These exclusions eliminate items that were selected by the "includeGlobs"
107
+ // * or "fileExtensions" setting.
108
+ // */
109
+ // "excludeGlobs": [],
110
+ //
111
+ // /**
112
+ // * Normally, when files are selected under a child folder, a corresponding folder will be created in
113
+ // * the destination folder. Specify flatten=true to discard the source path and copy all matching files
114
+ // * to the same folder. If two files have the same name an error will be reported.
115
+ // * The default value is false.
116
+ // */
117
+ // "flatten": false,
118
+ //
119
+ // /**
120
+ // * If true, filesystem hard links will be created instead of copying the file. Depending on the
121
+ // * operating system, this may be faster. (But note that it may cause unexpected behavior if a tool
122
+ // * modifies the link.) The default value is false.
123
+ // */
124
+ // "hardlink": false
125
+ // }
126
+ // ]
127
+ // }
128
+
129
+ {
130
+ "actionKind": "deleteGlobs",
131
+ "heftEvent": "clean",
132
+ "actionId": "defaultClean",
133
+ "globsToDelete": ["dist", "lib", "lib-amd", "lib-commonjs", "lib-es6", "temp"]
134
+ }
135
+ ],
136
+
137
+ /**
138
+ * The list of Heft plugins to be loaded.
139
+ */
140
+ "heftPlugins": [
141
+ // {
142
+ // /**
143
+ // * The path to the plugin package.
144
+ // */
145
+ // "plugin": "path/to/my-plugin",
146
+ //
147
+ // /**
148
+ // * An optional object that provides additional settings that may be defined by the plugin.
149
+ // */
150
+ // // "options": { }
151
+ // }
152
+ { "plugin": "@rushstack/heft-jest-plugin" },
153
+ { "plugin": "@rushstack/heft-sass-plugin" },
154
+ { "plugin": "@rushstack/heft-webpack5-plugin" }
155
+ ]
156
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "@rushstack/heft-jest-plugin/includes/jest-shared.config.json",
3
+
4
+ "testEnvironment": "jest-environment-jsdom"
5
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "operationSettings": [
3
+ {
4
+ "operationName": "_phase:build",
5
+ "outputFolderNames": ["dist", "lib", "lib-amd", "lib-commonjs", "lib-es6", "temp"]
6
+ },
7
+ {
8
+ "operationName": "build",
9
+ "outputFolderNames": ["dist", "lib", "lib-amd", "lib-commonjs", "lib-es6", "temp"]
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Configuration for @rushstack/heft-sass-plugin
3
+ *
4
+ * This optional additional file customizes Sass parsing, module resolution, and emitting of
5
+ * Typescript .d.ts files.
6
+ */
7
+ {
8
+ "$schema": "https://developer.microsoft.com/json-schemas/heft/heft-sass-plugin.schema.json",
9
+
10
+ /**
11
+ * Optionally specifies another JSON config file that this file extends from. This provides a way for standard
12
+ * settings to be shared across multiple projects.
13
+ */
14
+ // "extends": "base-project/config/serve-command.json",
15
+
16
+ /**
17
+ * The root directory for project source code.
18
+ *
19
+ * Default value: "src/"
20
+ */
21
+ // "srcFolder": "src/",
22
+
23
+ /**
24
+ * Output directory for generated Sass typings.
25
+ *
26
+ * Default value: "temp/sass-ts/"
27
+ */
28
+ // "generatedTsFolder": "temp/sass-ts/",
29
+
30
+ /**
31
+ * Determines whether export values are wrapped in a default property, or not.
32
+ *
33
+ * Default value: true
34
+ */
35
+ // "exportAsDefault": false,
36
+
37
+ /**
38
+ * If specified, folders where compiled CSS files will be emitted to. They will be named by appending
39
+ * ".css" to the source file name for ease of reference translation.
40
+ *
41
+ * Default value: undefined
42
+ */
43
+ // "cssOutputFolders": ["lib", "lib-commonjs"],
44
+
45
+ /**
46
+ * Files with these extensions will pass through the Sass transpiler for typings generation.
47
+ *
48
+ * Default value: [".sass", ".scss", ".css"]
49
+ */
50
+ "fileExtensions": [".sass", ".scss"]
51
+
52
+ /**
53
+ * A list of paths used when resolving Sass imports. The paths should be relative to the project root.
54
+ *
55
+ * Default value: ["node_modules", "src"]
56
+ */
57
+ // "importIncludePaths": ["node_modules", "src"],
58
+
59
+ /**
60
+ * A list of file paths relative to the "src" folder that should be excluded from typings generation.
61
+ *
62
+ * Default value: undefined
63
+ */
64
+ // "excludeFiles": []
65
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Configures the TypeScript plugin for Heft. This plugin also manages linting.
3
+ */
4
+ {
5
+ "$schema": "https://developer.microsoft.com/json-schemas/heft/typescript.schema.json",
6
+
7
+ /**
8
+ * Optionally specifies another JSON config file that this file extends from. This provides a way for standard
9
+ * settings to be shared across multiple projects.
10
+ */
11
+ // "extends": "base-project/config/typescript.json",
12
+
13
+ /**
14
+ * If provided, emit these module kinds in addition to the modules specified in the tsconfig.
15
+ * Note that this option only applies to the main tsconfig.json configuration.
16
+ */
17
+ "additionalModuleKindsToEmit": [
18
+ // {
19
+ // /**
20
+ // * (Required) Must be one of "commonjs", "amd", "umd", "system", "es2015", "esnext"
21
+ // */
22
+ // "moduleKind": "amd",
23
+ //
24
+ // /**
25
+ // * (Required) The name of the folder where the output will be written.
26
+ // */
27
+ // "outFolderName": "lib-amd"
28
+ // }
29
+
30
+ {
31
+ "moduleKind": "commonjs",
32
+ "outFolderName": "lib-commonjs"
33
+ }
34
+ ],
35
+
36
+ /**
37
+ * If true, emit CommonJS module output to the folder specified in the tsconfig "outDir" compiler option with the .cjs extension alongside (or instead of, if TSConfig specifies CommonJS) the default compilation output.
38
+ */
39
+ // "emitCjsExtensionForCommonJS": true,
40
+
41
+ /**
42
+ * If true, emit ESNext module output to the folder specified in the tsconfig "outDir" compiler option with the .mjs extension alongside (or instead of, if TSConfig specifies ESNext) the default compilation output.
43
+ */
44
+ // "emitMjsExtensionForESModule": true,
45
+
46
+ /**
47
+ * Specifies the intermediary folder that tests will use. Because Jest uses the
48
+ * Node.js runtime to execute tests, the module format must be CommonJS.
49
+ *
50
+ * The default value is "lib".
51
+ */
52
+ "emitFolderNameForTests": "lib-commonjs",
53
+
54
+ /**
55
+ * If set to "true", the TSlint task will not be invoked.
56
+ */
57
+ // "disableTslint": true,
58
+
59
+ /**
60
+ * Set this to change the maximum number of file handles that will be opened concurrently for writing.
61
+ * The default is 50.
62
+ */
63
+ // "maxWriteParallelism": 50,
64
+
65
+ /**
66
+ * Configures additional file types that should be copied into the TypeScript compiler's emit folders, for example
67
+ * so that these files can be resolved by import statements.
68
+ */
69
+ "staticAssetsToCopy": {
70
+ /**
71
+ * File extensions that should be copied from the src folder to the destination folder(s).
72
+ */
73
+ "fileExtensions": [
74
+ ".aac",
75
+ ".css",
76
+ ".eot",
77
+ ".gif",
78
+ ".jpeg",
79
+ ".jpg",
80
+ ".json",
81
+ ".m4a",
82
+ ".mp3",
83
+ ".mp4",
84
+ ".oga",
85
+ ".otf",
86
+ ".png",
87
+ ".scss",
88
+ ".svg",
89
+ ".ttf",
90
+ ".wav",
91
+ ".webm",
92
+ ".webp",
93
+ ".woff",
94
+ ".woff2"
95
+ ]
96
+
97
+ /**
98
+ * Glob patterns that should be explicitly included.
99
+ */
100
+ // "includeGlobs": [
101
+ // "some/path/*.js"
102
+ // ],
103
+
104
+ /**
105
+ * Glob patterns that should be explicitly excluded. This takes precedence over globs listed
106
+ * in "includeGlobs" and files that match the file extensions provided in "fileExtensions".
107
+ */
108
+ // "excludeGlobs": [
109
+ // "some/path/*.css"
110
+ // ]
111
+ }
112
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "http://json.schemastore.org/tsconfig",
3
+
4
+ "compilerOptions": {
5
+ "outDir": "../../../../../lib",
6
+ "rootDir": "../../../../../src",
7
+ "rootDirs": ["../../../../../src", "../../../../../temp/sass-ts"],
8
+
9
+ "forceConsistentCasingInFileNames": true,
10
+ "jsx": "react",
11
+ "declaration": true,
12
+ "sourceMap": true,
13
+ "declarationMap": true,
14
+ "inlineSources": true,
15
+ "experimentalDecorators": true,
16
+ "strict": true,
17
+ "useUnknownInCatchVariables": false,
18
+ "esModuleInterop": true,
19
+ "noEmitOnError": false,
20
+ "allowUnreachableCode": false,
21
+ "importHelpers": true,
22
+
23
+ "types": [],
24
+
25
+ "module": "esnext",
26
+ "moduleResolution": "node",
27
+ "target": "es5",
28
+ "lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"]
29
+ },
30
+ "include": ["../../../../../src/**/*.ts", "../../../../../src/**/*.tsx"]
31
+ }
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
5
+ const createWebpackConfigCommon = require('../../shared/webpack-base.config');
6
+
7
+ module.exports = function createWebpackConfig({ env, argv, projectRoot, configOverride }) {
8
+ // Documentation: https://webpack.js.org/configuration/
9
+ const applicationOverrides = {
10
+ target: ['web', 'es5'],
11
+ entry: {
12
+ app: path.resolve(projectRoot, 'lib', 'start.js')
13
+ },
14
+ optimization: {
15
+ splitChunks: {
16
+ chunks: 'all'
17
+ }
18
+ },
19
+ plugins: [
20
+ // NOTE: If your project's webpack.config.js provides its own "HtmlWebpackPlugin" configuration,
21
+ // it will replace the default definition here. This replacement is implemented
22
+ // using mergeWithCustomize() in shared/webpack-base.config.js
23
+
24
+ // See here for documentation: https://github.com/jantimon/html-webpack-plugin
25
+ new HtmlWebpackPlugin({
26
+ filename: 'index.html',
27
+ template: path.resolve(projectRoot, 'assets', 'index.html')
28
+ })
29
+ ]
30
+ };
31
+
32
+ return createWebpackConfigCommon({
33
+ env: env,
34
+ argv: argv,
35
+ projectRoot: projectRoot,
36
+ configOverride: createWebpackConfigCommon.merge(applicationOverrides, configOverride)
37
+ });
38
+ };
@@ -7,6 +7,12 @@
7
7
  {
8
8
  "$schema": "https://developer.microsoft.com/json-schemas/heft/api-extractor-task.schema.json"
9
9
 
10
+ /**
11
+ * Optionally specifies another JSON config file that this file extends from. This provides a way for standard
12
+ * settings to be shared across multiple projects.
13
+ */
14
+ // "extends": "base-project/config/api-extractor-task.json",
15
+
10
16
  /**
11
17
  * If set to true, use the project's TypeScript compiler version for API Extractor's
12
18
  * analysis. API Extractor's included TypeScript compiler can generally correctly