@teambit/react 0.0.566 → 0.0.570
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/compositions-app.tsx +31 -0
- package/dist/react.env.d.ts +0 -2
- package/dist/react.env.js +1 -38
- package/dist/react.env.js.map +1 -1
- package/dist/webpack/webpack.config.component.dev.d.ts +1 -1
- package/dist/webpack/webpack.config.component.dev.js +9 -13
- package/dist/webpack/webpack.config.component.dev.js.map +1 -1
- package/highlighter-widget.tsx +19 -0
- package/mount.tsx +17 -0
- package/package-tar/teambit-react-0.0.570.tgz +0 -0
- package/package.json +46 -61
- package/react.composition.tsx +7 -0
- package/react.ui.runtime.tsx +35 -0
- package/templates/react-app/files/app-root.ts +10 -0
- package/templates/react-app/files/app.ts +30 -0
- package/templates/react-app/files/aspect.ts +10 -0
- package/templates/react-app/files/compositions.ts +11 -0
- package/templates/react-app/files/doc.ts +29 -0
- package/templates/react-app/files/index.ts +10 -0
- package/templates/react-app/files/main.runtime.ts +22 -0
- package/templates/react-app/index.ts +47 -0
- package/templates/react-component/files/component.ts +25 -0
- package/templates/react-component/files/composition.ts +16 -0
- package/templates/react-component/files/docs.ts +32 -0
- package/templates/react-component/files/test.ts +19 -0
- package/templates/react-component/index.ts +40 -0
- package/templates/react-component-js/files/component.ts +18 -0
- package/templates/react-component-js/files/composition.ts +16 -0
- package/templates/react-component-js/files/docs.ts +32 -0
- package/templates/react-component-js/files/test.ts +21 -0
- package/templates/react-component-js/index.ts +38 -0
- package/templates/react-context/files/composition.ts +27 -0
- package/templates/react-context/files/context-provider.ts +27 -0
- package/templates/react-context/files/context.ts +21 -0
- package/templates/react-context/files/docs.ts +51 -0
- package/templates/react-context/files/test.ts +18 -0
- package/templates/react-context/index.ts +32 -0
- package/templates/react-env/files/aspect.ts +10 -0
- package/templates/react-env/files/doc.ts +163 -0
- package/templates/react-env/files/index.ts +10 -0
- package/templates/react-env/files/jest.config.ts +21 -0
- package/templates/react-env/files/main.runtime.ts +84 -0
- package/templates/react-env/files/preview.runtime.ts +27 -0
- package/templates/react-env/files/typescript.config.ts +21 -0
- package/templates/react-env/files/webpack.config.ts +48 -0
- package/templates/react-env/index.ts +51 -0
- package/templates/react-hook/files/component.ts +16 -0
- package/templates/react-hook/files/composition.ts +23 -0
- package/templates/react-hook/files/docs.ts +33 -0
- package/templates/react-hook/files/test.ts +20 -0
- package/templates/react-hook/index.ts +21 -0
- package/templates/react-workspace/index.ts +27 -0
- package/templates/react-workspace-app/index.ts +20 -0
- package/templates/react-workspace-deprecated/index.ts +28 -0
- package/templates/react-workspace-lib/index.ts +21 -0
- package/templates/workspace-common/files/eslint-config.ts +6 -0
- package/templates/workspace-common/files/git-ignore.ts +113 -0
- package/templates/workspace-common/files/prettier-config.ts +5 -0
- package/templates/workspace-common/files/readme-file.ts +36 -0
- package/templates/workspace-common/files/ts-config.ts +7 -0
- package/templates/workspace-common/files/types/asset.ts +28 -0
- package/templates/workspace-common/files/types/style.ts +43 -0
- package/templates/workspace-common/files/workspace-config.ts +58 -0
- package/templates/workspace-common/generate-files.ts +51 -0
- package/templates/workspace-common/index.ts +1 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
- package/typescript/asset.d.ts +29 -0
- package/typescript/style.d.ts +42 -0
- package/webpack/postcss.config.ts +21 -0
- package/webpack/webpack.config.base.prod.ts +123 -0
- package/webpack/webpack.config.base.ts +365 -0
- package/webpack/webpack.config.component.dev.ts +99 -0
- package/webpack/webpack.config.component.prod.ts +39 -0
- package/webpack/webpack.config.env.dev.ts +21 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export function gitIgnore() {
|
|
2
|
+
return `# Bit
|
|
3
|
+
.bit
|
|
4
|
+
public
|
|
5
|
+
|
|
6
|
+
# Logs
|
|
7
|
+
logs
|
|
8
|
+
*.log
|
|
9
|
+
npm-debug.log*
|
|
10
|
+
yarn-debug.log*
|
|
11
|
+
yarn-error.log*
|
|
12
|
+
lerna-debug.log*
|
|
13
|
+
|
|
14
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
15
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
16
|
+
|
|
17
|
+
# Runtime data
|
|
18
|
+
pids
|
|
19
|
+
*.pid
|
|
20
|
+
*.seed
|
|
21
|
+
*.pid.lock
|
|
22
|
+
|
|
23
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
24
|
+
lib-cov
|
|
25
|
+
|
|
26
|
+
# Coverage directory used by tools like istanbul
|
|
27
|
+
coverage
|
|
28
|
+
*.lcov
|
|
29
|
+
|
|
30
|
+
# nyc test coverage
|
|
31
|
+
.nyc_output
|
|
32
|
+
|
|
33
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
34
|
+
.grunt
|
|
35
|
+
|
|
36
|
+
# Bower dependency directory (https://bower.io/)
|
|
37
|
+
bower_components
|
|
38
|
+
|
|
39
|
+
# node-waf configuration
|
|
40
|
+
.lock-wscript
|
|
41
|
+
|
|
42
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
43
|
+
build/Release
|
|
44
|
+
|
|
45
|
+
# Dependency directories
|
|
46
|
+
node_modules/
|
|
47
|
+
jspm_packages/
|
|
48
|
+
|
|
49
|
+
# TypeScript v1 declaration files
|
|
50
|
+
typings/
|
|
51
|
+
|
|
52
|
+
# TypeScript cache
|
|
53
|
+
*.tsbuildinfo
|
|
54
|
+
|
|
55
|
+
# Optional npm cache directory
|
|
56
|
+
.npm
|
|
57
|
+
|
|
58
|
+
# Optional eslint cache
|
|
59
|
+
.eslintcache
|
|
60
|
+
|
|
61
|
+
# Microbundle cache
|
|
62
|
+
.rpt2_cache/
|
|
63
|
+
.rts2_cache_cjs/
|
|
64
|
+
.rts2_cache_es/
|
|
65
|
+
.rts2_cache_umd/
|
|
66
|
+
|
|
67
|
+
# Optional REPL history
|
|
68
|
+
.node_repl_history
|
|
69
|
+
|
|
70
|
+
# Output of 'npm pack'
|
|
71
|
+
*.tgz
|
|
72
|
+
|
|
73
|
+
# Yarn Integrity file
|
|
74
|
+
.yarn-integrity
|
|
75
|
+
|
|
76
|
+
# dotenv environment variables file
|
|
77
|
+
.env
|
|
78
|
+
.env.test
|
|
79
|
+
|
|
80
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
81
|
+
.cache
|
|
82
|
+
|
|
83
|
+
# Next.js build output
|
|
84
|
+
.next
|
|
85
|
+
|
|
86
|
+
# Nuxt.js build / generate output
|
|
87
|
+
.nuxt
|
|
88
|
+
dist
|
|
89
|
+
|
|
90
|
+
# Gatsby files
|
|
91
|
+
.cache/
|
|
92
|
+
|
|
93
|
+
# vuepress build output
|
|
94
|
+
.vuepress/dist
|
|
95
|
+
|
|
96
|
+
# Serverless directories
|
|
97
|
+
.serverless/
|
|
98
|
+
|
|
99
|
+
# FuseBox cache
|
|
100
|
+
.fusebox/
|
|
101
|
+
|
|
102
|
+
# DynamoDB Local files
|
|
103
|
+
.dynamodb/
|
|
104
|
+
|
|
105
|
+
# TernJS port file
|
|
106
|
+
.tern-port
|
|
107
|
+
|
|
108
|
+
.history
|
|
109
|
+
|
|
110
|
+
.DS_Store
|
|
111
|
+
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function readme() {
|
|
2
|
+
return `# Welcome to your Bit Workspace
|
|
3
|
+
|
|
4
|
+
To get started straight away run \`bit start\` and open [localhost:3000](http://localhost:3000). It may take a while to build the first time you run this command as it is building the whole User Interface for your development environment.
|
|
5
|
+
|
|
6
|
+
\`\`\`bash
|
|
7
|
+
bit start
|
|
8
|
+
\`\`\`
|
|
9
|
+
|
|
10
|
+
## What's included
|
|
11
|
+
|
|
12
|
+
- **workspace.jsonc**
|
|
13
|
+
|
|
14
|
+
This is the main configuration file of your bit workspace. Here you can modify the workspace name and icon as well as default directory and scope. It is where dependencies are found when you install anything. It is also where you register aspects, bit extensions as well as apply the environments for your components. This workspace has been setup so that all components use the React env. However you can create other components and apply other envs to them such as node, html, angular and aspect envs.
|
|
15
|
+
|
|
16
|
+
- **.bitmap**
|
|
17
|
+
|
|
18
|
+
This is an auto-generated file and includes the mapping of your components. There is one component included here. In order to remove this component you can run the following command.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
- **Demo Components**
|
|
22
|
+
|
|
23
|
+
A folder (unless the --empty flag was used) containing demo components are included in this workspace. These components are used to demonstrate the different features of Bit. If you would like to remove these components you can run the following command.
|
|
24
|
+
|
|
25
|
+
\`\`\`jsx
|
|
26
|
+
bit remove "ui/*" --delete files
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
This removes the components from the bitmap as well as removes the files.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
- **.gitignore**
|
|
33
|
+
|
|
34
|
+
Ignoring any files from version control
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const assetTypes = `declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
declare module '*.jpg' {
|
|
13
|
+
const value: any;
|
|
14
|
+
export = value;
|
|
15
|
+
}
|
|
16
|
+
declare module '*.jpeg' {
|
|
17
|
+
const value: any;
|
|
18
|
+
export = value;
|
|
19
|
+
}
|
|
20
|
+
declare module '*.gif' {
|
|
21
|
+
const value: any;
|
|
22
|
+
export = value;
|
|
23
|
+
}
|
|
24
|
+
declare module '*.bmp' {
|
|
25
|
+
const value: any;
|
|
26
|
+
export = value;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const styleTypes = `declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@teambit/generator';
|
|
2
|
+
import { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';
|
|
3
|
+
import { parse, assign } from 'comment-json';
|
|
4
|
+
|
|
5
|
+
export async function workspaceConfig({ name, defaultScope, empty }: WorkspaceContext) {
|
|
6
|
+
const scope = defaultScope || 'company.scope';
|
|
7
|
+
const configParsed = await getWorkspaceConfigTemplateParsed();
|
|
8
|
+
configParsed['teambit.workspace/workspace'].name = name;
|
|
9
|
+
configParsed['teambit.workspace/workspace'].defaultScope = scope;
|
|
10
|
+
configParsed['teambit.dependencies/dependency-resolver'].packageManager = 'teambit.dependencies/pnpm';
|
|
11
|
+
configParsed['teambit.dependencies/dependency-resolver'].policy = {
|
|
12
|
+
dependencies: {
|
|
13
|
+
'@teambit/eslint-config-bit-react': '~0.0.367',
|
|
14
|
+
'@typescript-eslint/eslint-plugin': '4.29.3',
|
|
15
|
+
'eslint-import-resolver-node': '0.3.6',
|
|
16
|
+
'eslint-plugin-import': '2.22.1',
|
|
17
|
+
'eslint-plugin-jest': '24.4.0',
|
|
18
|
+
'eslint-plugin-jsx-a11y': '6.4.1',
|
|
19
|
+
'eslint-plugin-mdx': '1.15.0',
|
|
20
|
+
'eslint-plugin-react': '7.25.1',
|
|
21
|
+
},
|
|
22
|
+
peerDependencies: {
|
|
23
|
+
'@testing-library/react': '12.0.0',
|
|
24
|
+
react: '17.0.2',
|
|
25
|
+
'react-dom': '17.0.2',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const variants = {
|
|
30
|
+
'teambit.workspace/variants': empty
|
|
31
|
+
? {
|
|
32
|
+
'*': {
|
|
33
|
+
'teambit.react/react': {},
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
: parse(`{
|
|
37
|
+
"{ui/**}, {pages/**}": {
|
|
38
|
+
// uses the custom env
|
|
39
|
+
"${scope}/envs/my-react": {},
|
|
40
|
+
// uncomment the line below if you remove the custom env and remove the line above
|
|
41
|
+
// "teambit.react/react": {},
|
|
42
|
+
},
|
|
43
|
+
"{themes/**}": {
|
|
44
|
+
"teambit.react/react": {},
|
|
45
|
+
},
|
|
46
|
+
"{content/**}": {
|
|
47
|
+
"teambit.mdx/mdx": {},
|
|
48
|
+
},
|
|
49
|
+
"{envs/**}, {extensions/**}": {
|
|
50
|
+
"teambit.harmony/aspect": {},
|
|
51
|
+
},
|
|
52
|
+
}`),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const configMerged = assign(configParsed, variants);
|
|
56
|
+
|
|
57
|
+
return stringifyWorkspaceConfig(configMerged);
|
|
58
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@teambit/generator';
|
|
2
|
+
import { workspaceConfig } from './files/workspace-config';
|
|
3
|
+
import { readme } from './files/readme-file';
|
|
4
|
+
import { gitIgnore } from './files/git-ignore';
|
|
5
|
+
import { assetTypes } from './files/types/asset';
|
|
6
|
+
import { styleTypes } from './files/types/style';
|
|
7
|
+
import { eslintConfig } from './files/eslint-config';
|
|
8
|
+
import { tsConfig } from './files/ts-config';
|
|
9
|
+
import { prettierConfig } from './files/prettier-config';
|
|
10
|
+
|
|
11
|
+
type GeneratedFile = {
|
|
12
|
+
relativePath: string;
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export async function generateFiles(context: WorkspaceContext): Promise<GeneratedFile[]> {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
relativePath: 'workspace.jsonc',
|
|
20
|
+
content: await workspaceConfig(context),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
relativePath: `.gitignore`,
|
|
24
|
+
content: gitIgnore(),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
relativePath: `README.md`,
|
|
28
|
+
content: readme(),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
relativePath: `.eslintrc.js`,
|
|
32
|
+
content: eslintConfig,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
relativePath: `tsconfig.json`,
|
|
36
|
+
content: tsConfig,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
relativePath: `.prettierrc.js`,
|
|
40
|
+
content: prettierConfig,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
relativePath: `types/asset.d.ts`,
|
|
44
|
+
content: assetTypes,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
relativePath: `types/style.d.ts`,
|
|
48
|
+
content: styleTypes,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateFiles } from './generate-files';
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
export const postCssConfig = {
|
|
3
|
+
// Necessary for external CSS imports to work
|
|
4
|
+
// https://github.com/facebook/create-react-app/issues/2677
|
|
5
|
+
ident: 'postcss',
|
|
6
|
+
plugins: [
|
|
7
|
+
// eslint-disable-next-line global-require
|
|
8
|
+
require.resolve('postcss-flexbugs-fixes'),
|
|
9
|
+
// eslint-disable-next-line global-require
|
|
10
|
+
require('postcss-preset-env')({
|
|
11
|
+
autoprefixer: {
|
|
12
|
+
flexbox: 'no-2009',
|
|
13
|
+
},
|
|
14
|
+
stage: 3,
|
|
15
|
+
}),
|
|
16
|
+
// Adds PostCSS Normalize as the reset css with default options,
|
|
17
|
+
// so that it honors browserslist config in package.json
|
|
18
|
+
// which in turn let's users customize the target behavior as per their needs.
|
|
19
|
+
require.resolve('postcss-normalize'),
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import WorkboxWebpackPlugin from 'workbox-webpack-plugin';
|
|
2
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
3
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
4
|
+
import { Configuration } from 'webpack';
|
|
5
|
+
import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
|
|
6
|
+
|
|
7
|
+
// This is the production and development configuration.
|
|
8
|
+
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
9
|
+
// eslint-disable-next-line complexity
|
|
10
|
+
export default function (): Configuration {
|
|
11
|
+
return {
|
|
12
|
+
optimization: {
|
|
13
|
+
minimize: true,
|
|
14
|
+
minimizer: [
|
|
15
|
+
// This is only used in production mode
|
|
16
|
+
new TerserPlugin({
|
|
17
|
+
terserOptions: {
|
|
18
|
+
parse: {
|
|
19
|
+
// We want terser to parse ecma 8 code. However, we don't want it
|
|
20
|
+
// to apply any minification steps that turns valid ecma 5 code
|
|
21
|
+
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
22
|
+
// sections only apply transformations that are ecma 5 safe
|
|
23
|
+
// https://github.com/facebook/create-react-app/pull/4234
|
|
24
|
+
ecma: 8,
|
|
25
|
+
},
|
|
26
|
+
compress: {
|
|
27
|
+
ecma: 5,
|
|
28
|
+
warnings: false,
|
|
29
|
+
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
30
|
+
// https://github.com/facebook/create-react-app/issues/2376
|
|
31
|
+
// Pending further investigation:
|
|
32
|
+
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
33
|
+
comparisons: false,
|
|
34
|
+
// Disabled because of an issue with Terser breaking valid code:
|
|
35
|
+
// https://github.com/facebook/create-react-app/issues/5250
|
|
36
|
+
// Pending further investigation:
|
|
37
|
+
// https://github.com/terser-js/terser/issues/120
|
|
38
|
+
inline: 2,
|
|
39
|
+
},
|
|
40
|
+
mangle: {
|
|
41
|
+
safari10: true,
|
|
42
|
+
},
|
|
43
|
+
output: {
|
|
44
|
+
ecma: 5,
|
|
45
|
+
comments: false,
|
|
46
|
+
// Turned on because emoji and regex is not minified properly using default
|
|
47
|
+
// https://github.com/facebook/create-react-app/issues/2488
|
|
48
|
+
ascii_only: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
new CssMinimizerPlugin({
|
|
53
|
+
minimizerOptions: {
|
|
54
|
+
preset: [
|
|
55
|
+
'default',
|
|
56
|
+
{
|
|
57
|
+
minifyFontValues: { removeQuotes: false },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
],
|
|
63
|
+
// Automatically split vendor and commons
|
|
64
|
+
// https://twitter.com/wSokra/status/969633336732905474
|
|
65
|
+
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
66
|
+
splitChunks: {
|
|
67
|
+
chunks: 'all',
|
|
68
|
+
// name: false,
|
|
69
|
+
},
|
|
70
|
+
// Keep the runtime chunk separated to enable long term caching
|
|
71
|
+
// https://twitter.com/wSokra/status/969679223278505985
|
|
72
|
+
// https://github.com/facebook/create-react-app/issues/5358
|
|
73
|
+
runtimeChunk: {
|
|
74
|
+
name: (entrypoint) => `runtime-${entrypoint.name}`,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
plugins: [
|
|
79
|
+
// Generate an asset manifest file with the following content:
|
|
80
|
+
// - "files" key: Mapping of all asset filenames to their corresponding
|
|
81
|
+
// output file so that tools can pick it up without having to parse
|
|
82
|
+
// `index.html`
|
|
83
|
+
// can be used to reconstruct the HTML if necessary
|
|
84
|
+
new WebpackManifestPlugin({
|
|
85
|
+
fileName: 'asset-manifest.json',
|
|
86
|
+
publicPath: 'public',
|
|
87
|
+
generate: (seed, files, entrypoints) => {
|
|
88
|
+
const manifestFiles = files.reduce((manifest, file) => {
|
|
89
|
+
manifest[file.name] = file.path;
|
|
90
|
+
return manifest;
|
|
91
|
+
}, seed);
|
|
92
|
+
const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));
|
|
93
|
+
|
|
94
|
+
// @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276
|
|
95
|
+
return {
|
|
96
|
+
files: manifestFiles,
|
|
97
|
+
entrypoints: entrypointFiles,
|
|
98
|
+
} as Record<string, string>;
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
// Generate a service worker script that will precache, and keep up to date,
|
|
102
|
+
// the HTML & assets that are part of the webpack build.
|
|
103
|
+
new WorkboxWebpackPlugin.GenerateSW({
|
|
104
|
+
clientsClaim: true,
|
|
105
|
+
exclude: [/\.map$/, /asset-manifest\.json$/],
|
|
106
|
+
// importWorkboxFrom: 'cdn',
|
|
107
|
+
navigateFallback: 'public/index.html',
|
|
108
|
+
navigateFallbackDenylist: [
|
|
109
|
+
// Exclude URLs starting with /_, as they're likely an API call
|
|
110
|
+
new RegExp('^/_'),
|
|
111
|
+
// Exclude any URLs whose last part seems to be a file extension
|
|
112
|
+
// as they're likely a resource and not a SPA route.
|
|
113
|
+
// URLs containing a "?" character won't be blacklisted as they're likely
|
|
114
|
+
// a route with query params (e.g. auth callbacks).
|
|
115
|
+
new RegExp('/[^/?]+\\.[^/]+$'),
|
|
116
|
+
],
|
|
117
|
+
}),
|
|
118
|
+
].filter(Boolean),
|
|
119
|
+
// Turn off performance processing because we utilize
|
|
120
|
+
// our own hints via the FileSizeReporter
|
|
121
|
+
performance: false,
|
|
122
|
+
};
|
|
123
|
+
}
|