Skip to content

Commit

Permalink
Merge pull request #3204 from microsoft/octogonz/heft-web-rig-revamp
Browse files Browse the repository at this point in the history
[heft-web-rig] Add an "app" profile, upgrade to Webpack 5, implement new CSS rules
  • Loading branch information
octogonz authored Feb 11, 2022
2 parents fe5df23 + 55ef407 commit 39ec31f
Show file tree
Hide file tree
Showing 105 changed files with 6,037 additions and 4,063 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/build-tests-samples/heft-node-rig-tutorial](./build-tests-samples/heft-node-rig-tutorial/) | (Copy of sample project) Building this project is a regression test for Heft |
| [/build-tests-samples/heft-storybook-react-tutorial](./build-tests-samples/heft-storybook-react-tutorial/) | (Copy of sample project) Building this project is a regression test for Heft |
| [/build-tests-samples/heft-storybook-react-tutorial-storykit](./build-tests-samples/heft-storybook-react-tutorial-storykit/) | Storybook build dependencies for heft-storybook-react-tutorial |
| [/build-tests-samples/heft-web-rig-app-tutorial](./build-tests-samples/heft-web-rig-app-tutorial/) | (Copy of sample project) Building this project is a regression test for Heft |
| [/build-tests-samples/heft-web-rig-library-tutorial](./build-tests-samples/heft-web-rig-library-tutorial/) | (Copy of sample project) Building this project is a regression test for Heft |
| [/build-tests-samples/heft-webpack-basic-tutorial](./build-tests-samples/heft-webpack-basic-tutorial/) | (Copy of sample project) Building this project is a regression test for Heft |
| [/build-tests-samples/packlets-tutorial](./build-tests-samples/packlets-tutorial/) | (Copy of sample project) Building this project is a regression test for @rushstack/eslint-plugin-packlets |
| [/build-tests/api-documenter-test](./build-tests/api-documenter-test/) | Building this project is a regression test for api-documenter |
Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/schemas/README-ModifyingSchemas.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Important

If you change the Heft schemas, be sure to update the example files under **src/templates**.
If you change the Heft schemas, be sure to update the example files under **schemas/templates**.
The templates are used as a reference when updating the website documentation.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@
"_phase:build": ""
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@storybook/addon-actions": "~6.3.6",
"@storybook/addon-essentials": "~6.3.6",
"@storybook/addon-links": "~6.3.6",
"@storybook/cli": "~6.3.6",
"@storybook/components": "~6.3.0",
"@storybook/core-events": "~6.3.0",
"@storybook/react": "~6.3.6",
"@storybook/theming": "~6.3.0",
"@babel/core": "~7.17.0",
"@storybook/addon-actions": "~6.4.18",
"@storybook/addon-essentials": "~6.4.18",
"@storybook/addon-links": "~6.4.18",
"@storybook/cli": "~6.4.18",
"@storybook/components": "~6.4.18",
"@storybook/core-events": "~6.4.18",
"@storybook/react": "~6.4.18",
"@storybook/theming": "~6.4.18",
"@types/heft-jest": "1.0.1",
"@types/react-dom": "16.9.8",
"@types/react": "16.9.45",
"@types/react-dom": "16.9.14",
"@types/react": "16.14.23",
"@types/webpack-env": "1.13.0",
"babel-loader": "^8.2.2",
"css-loader": "~4.2.1",
"babel-loader": "~8.2.3",
"css-loader": "~5.2.7",
"jest": "~27.4.2",
"react-dom": "~16.13.1",
"react": "~16.13.1",
"style-loader": "~1.2.1",
"style-loader": "~2.0.0",
"terser-webpack-plugin": "~3.0.8",
"typescript": "~4.5.2",
"webpack": "~4.44.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/**
* The path to the plugin package.
*/
"plugin": "@rushstack/heft-webpack5-plugin"
"plugin": "@rushstack/heft-webpack4-plugin"

/**
* An optional object that provides additional settings that may be defined by the plugin.
Expand Down
15 changes: 8 additions & 7 deletions build-tests-samples/heft-storybook-react-tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
"scripts": {
"build": "heft build --clean",
"start": "heft start",
"storybook": "heft start --storybook",
"_phase:build": "heft build --clean",
"_phase:test": "heft test --no-build"
},
"devDependencies": {
"@rushstack/eslint-config": "workspace:*",
"@rushstack/heft-jest-plugin": "workspace:*",
"@rushstack/heft-storybook-plugin": "workspace:*",
"@rushstack/heft-webpack5-plugin": "workspace:*",
"@rushstack/heft-webpack4-plugin": "workspace:*",
"@rushstack/heft": "workspace:*",
"@types/heft-jest": "1.0.1",
"@types/react-dom": "16.9.8",
"@types/react": "16.9.45",
"@types/react-dom": "16.9.14",
"@types/react": "16.14.23",
"@types/webpack-env": "1.13.0",
"css-loader": "~4.2.1",
"css-loader": "~5.2.7",
"eslint": "~8.7.0",
"heft-storybook-react-tutorial-storykit": "workspace:*",
"html-webpack-plugin": "~5.5.0",
"html-webpack-plugin": "~4.5.2",
"react-dom": "~16.13.1",
"react": "~16.13.1",
"source-map-loader": "~1.1.2",
"style-loader": "~1.2.1",
"source-map-loader": "~1.1.3",
"style-loader": "~2.0.0",
"typescript": "~4.5.2",
"webpack": "~4.44.2"
}
Expand Down
7 changes: 7 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');

module.exports = {
extends: ['@rushstack/eslint-config/profile/web-app', '@rushstack/eslint-config/mixins/react'],
parserOptions: { tsconfigRootDir: __dirname }
};
8 changes: 8 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# heft-web-rig-app-tutorial

This is a copy of the
[heft-web-rig-app-tutorial](https://github.com/microsoft/rushstack-samples/tree/main/heft/heft-web-rig-app-tutorial)
tutorial project from the [rushstack-samples](https://github.com/microsoft/rushstack-samples) repo.

The copy here serves as a regression test, by using `"workspace:*"` references to the local projects in this repo.
Please update the copy from time to time to keep it in sync with the official tutorial.
12 changes: 12 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Example Application</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@rushstack/heft-web-rig/profiles/library/config/jest.config.json"
}
6 changes: 6 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/config/rig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",

"rigPackageName": "@rushstack/heft-web-rig",
"rigProfile": "library"
}
28 changes: 28 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "heft-web-rig-app-tutorial",
"description": "(Copy of sample project) Building this project is a regression test for Heft",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "heft test --clean",
"start": "heft start",
"_phase:build": "heft build --clean",
"_phase:test": "heft test --no-build"
},
"dependencies": {
"heft-web-rig-library-tutorial": "workspace:*",
"react": "~16.13.1",
"react-dom": "~16.13.1",
"tslib": "~2.3.1"
},
"devDependencies": {
"@rushstack/eslint-config": "workspace:*",
"@rushstack/heft-web-rig": "workspace:*",
"@rushstack/heft": "workspace:*",
"@types/heft-jest": "1.0.1",
"@types/react-dom": "16.9.14",
"@types/react": "16.14.23",
"@types/webpack-env": "1.13.0",
"typescript": "~4.5.2"
}
}
35 changes: 35 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/src/ExampleApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from 'react';
import { ToggleSwitch, IToggleEventArgs } from 'heft-web-rig-library-tutorial';

/**
* This React component renders the application page.
*/
export class ExampleApp extends React.Component {
public render(): React.ReactNode {
const appStyle: React.CSSProperties = {
backgroundColor: '#ffffff',
padding: '20px',
margin: '20px',
borderRadius: '5px',
width: '400px'
};

return (
<div style={appStyle}>
<h2>Hello, world!</h2>
<p>Here is an example control:</p>
<ToggleSwitch leftColor={'#800000'} rightColor={'#008000'} onToggle={this._onToggle} />

<p>Here is an example image:</p>
<img src={require('./example-image.png')} />
</div>
);
}

// React event handlers should be represented as fields instead of methods to ensure the "this" pointer
// is bound correctly. This form does not work with virtual/override inheritance, so use regular methods
// everywhere else.
private _onToggle = (sender: ToggleSwitch, args: IToggleEventArgs): void => {
console.log('Toggle switch changed: ' + args.sliderPosition);
};
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/src/start.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This file gets copied to the "lib" folder because its extension is registered in copy-static-assets.json
* Then Webpack uses css-loader to embed it in the application bundle, and then style-loader applies to the DOM.
*/
html,
body {
margin: 0;
height: 100%;
background-color: #c0c0c0;
font-family: Tahoma, sans-serif;
}
9 changes: 9 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/src/start.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ExampleApp } from './ExampleApp';

import './start.css';

const rootDiv: HTMLElement = document.getElementById('root') as HTMLElement;
ReactDOM.render(<ExampleApp />, rootDiv);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

// Note that Jest tests import the CommonJS files (from lib-commonjs/*.js)
// whereas Webpack will import the ESM files (from lib/*.js)
import { ToggleSwitch } from 'heft-web-rig-library-tutorial';

describe('ToggleSwitch', () => {
it('can be tested', () => {
expect(ToggleSwitch).toBeDefined();
});
});
6 changes: 6 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./node_modules/@rushstack/heft-web-rig/profiles/app/tsconfig-base.json",
"compilerOptions": {
"types": ["heft-jest", "webpack-env"]
}
}
28 changes: 28 additions & 0 deletions build-tests-samples/heft-web-rig-app-tutorial/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

const createWebpackConfig = require('@rushstack/heft-web-rig/profiles/app/webpack-base.config');

module.exports = function createConfig(env, argv) {
return createWebpackConfig({
env: env,
argv: argv,
projectRoot: __dirname,
// Documentation: https://webpack.js.org/configuration/
configOverride: {
resolve: {
alias: {
// Use the bundled library
'heft-web-rig-library-tutorial':
'heft-web-rig-library-tutorial/dist/heft-web-rig-library-tutorial.js'
}
},
performance: {
hints: env.production ? 'error' : false
// This specifies the bundle size limit that will trigger Webpack's warning saying:
// "The following entrypoint(s) combined asset size exceeds the recommended limit."
// maxEntrypointSize: 500000,
// maxAssetSize: 500000
}
}
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');

module.exports = {
extends: ['@rushstack/eslint-config/profile/web-app', '@rushstack/eslint-config/mixins/react'],
parserOptions: { tsconfigRootDir: __dirname }
};
8 changes: 8 additions & 0 deletions build-tests-samples/heft-web-rig-library-tutorial/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# heft-web-rig-library-tutorial

This is a copy of the
[heft-web-rig-library-tutorial](https://github.com/microsoft/rushstack-samples/tree/main/heft/heft-web-rig-library-tutorial)
tutorial project from the [rushstack-samples](https://github.com/microsoft/rushstack-samples) repo.

The copy here serves as a regression test, by using `"workspace:*"` references to the local projects in this repo.
Please update the copy from time to time to keep it in sync with the official tutorial.
Loading

0 comments on commit 39ec31f

Please sign in to comment.