@papillonarts/setup 0.7.0 → 0.9.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.
- package/babel/index.js +1 -1
- package/eslint/index.js +25 -10
- package/jest/config.js +5 -3
- package/package.json +2 -2
- package/storybook/index.ts +3 -0
- package/storybook/mainSetup.ts +278 -0
- package/storybook/managerSetup.ts +9 -0
- package/storybook/previewSetup.tsx +50 -0
- package/webpack/constant/index.ts +24 -0
- package/webpack/index.ts +27 -0
- package/webpack/loader/babelLoader.ts +38 -0
- package/webpack/loader/cssLoader.ts +13 -0
- package/webpack/loader/fontLoader.ts +8 -0
- package/webpack/loader/imageLoader.ts +8 -0
- package/webpack/loader/markdownLoader.ts +17 -0
- package/webpack/loader/postCSSLoader.ts +14 -0
- package/webpack/loader/{sassLoader.js → sassLoader.ts} +7 -14
- package/webpack/loader/svgrLoader.ts +17 -0
- package/webpack/plugin/bannerPlugin.ts +18 -0
- package/webpack/plugin/cleanWebpackPlugin.ts +27 -0
- package/webpack/plugin/copyWebpackPlugin.ts +18 -0
- package/webpack/plugin/cssMinimizerWebpackPlugin.ts +7 -0
- package/webpack/plugin/dotenvWebpack.ts +19 -0
- package/webpack/plugin/hotModuleReplacementPlugin.ts +7 -0
- package/webpack/plugin/htmlWebpackPlugin.ts +25 -0
- package/webpack/plugin/miniCSSExtractPlugin.ts +16 -0
- package/webpack/plugin/moduleConcatenationPlugin.ts +7 -0
- package/webpack/plugin/webpackBundleAnalyzer.ts +7 -0
- package/webpack/plugin/webpackManifestPlugin.ts +15 -0
- package/webpack/server/devServer.ts +13 -0
- package/webpack/setup/commonSetup.ts +36 -0
- package/webpack/setup/developmentSetup.ts +52 -0
- package/webpack/setup/productionSetup.ts +66 -0
- package/storybook/index.js +0 -26
- package/storybook/mainSetup.js +0 -265
- package/storybook/managerSetup.js +0 -16
- package/storybook/previewSetup.js +0 -54
- package/webpack/constant/index.js +0 -15
- package/webpack/index.js +0 -202
- package/webpack/loader/babelLoader.js +0 -31
- package/webpack/loader/cssLoader.js +0 -22
- package/webpack/loader/fontLoader.js +0 -14
- package/webpack/loader/imageLoader.js +0 -14
- package/webpack/loader/markdownLoader.js +0 -20
- package/webpack/loader/postCSSLoader.js +0 -22
- package/webpack/loader/svgrLoader.js +0 -25
- package/webpack/plugin/bannerPlugin.js +0 -16
- package/webpack/plugin/cleanWebpackPlugin.js +0 -31
- package/webpack/plugin/copyWebpackPlugin.js +0 -24
- package/webpack/plugin/cssMinimizerWebpackPlugin.js +0 -13
- package/webpack/plugin/dotenvWebpack.js +0 -35
- package/webpack/plugin/hotModuleReplacementPlugin.js +0 -13
- package/webpack/plugin/htmlWebpackPlugin.js +0 -42
- package/webpack/plugin/miniCSSExtractPlugin.js +0 -22
- package/webpack/plugin/moduleConcatenationPlugin.js +0 -13
- package/webpack/plugin/webpackBundleAnalyzer.js +0 -15
- package/webpack/plugin/webpackManifestPlugin.js +0 -21
- package/webpack/server/devServer.js +0 -21
- package/webpack/setup/commonSetup.js +0 -37
- package/webpack/setup/developmentSetup.js +0 -54
- package/webpack/setup/productionSetup.js +0 -59
package/babel/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
presets: ['@babel/preset-env', '@babel/preset-react'],
|
|
4
|
+
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
|
5
5
|
plugins: [['@babel/plugin-transform-react-jsx', {
|
|
6
6
|
runtime: 'automatic'
|
|
7
7
|
}], '@babel/plugin-transform-runtime', 'syntax-async-functions']
|
package/eslint/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// https://typescript-eslint.io/users/configs/
|
|
4
|
+
|
|
3
5
|
module.exports = {
|
|
4
6
|
env: {
|
|
5
7
|
amd: true,
|
|
@@ -11,7 +13,7 @@ module.exports = {
|
|
|
11
13
|
mocha: true,
|
|
12
14
|
node: true
|
|
13
15
|
},
|
|
14
|
-
"extends": ['eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings', '
|
|
16
|
+
"extends": ['eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings', 'plugin:react/recommended', 'plugin:jsx-a11y/recommended', 'plugin:jest/recommended', 'prettier', 'plugin:@typescript-eslint/stylistic-type-checked'],
|
|
15
17
|
globals: {
|
|
16
18
|
document: false,
|
|
17
19
|
expect: false,
|
|
@@ -20,17 +22,19 @@ module.exports = {
|
|
|
20
22
|
renderMount: false,
|
|
21
23
|
renderShallow: false
|
|
22
24
|
},
|
|
23
|
-
parser: '@
|
|
25
|
+
parser: '@typescript-eslint/parser',
|
|
26
|
+
// https://typescript-eslint.io/packages/parser/#configuration
|
|
24
27
|
parserOptions: {
|
|
25
28
|
ecmaFeatures: {
|
|
26
29
|
jsx: true
|
|
27
30
|
},
|
|
28
31
|
ecmaVersion: 16,
|
|
29
|
-
|
|
32
|
+
projectService: {
|
|
33
|
+
allowDefaultProject: ['*.js', '*.jsx', '*.ts', '*.tsx']
|
|
34
|
+
}
|
|
30
35
|
},
|
|
31
36
|
plugins: ['react', 'react-hooks', 'jsx-a11y', 'jest', 'prettier'],
|
|
32
37
|
rules: {
|
|
33
|
-
'comma-dangle': 2,
|
|
34
38
|
'import/named': 2,
|
|
35
39
|
'import/no-extraneous-dependencies': [0, {
|
|
36
40
|
devDependencies: ['**/*.test.js', '**/*.story.js']
|
|
@@ -38,28 +42,39 @@ module.exports = {
|
|
|
38
42
|
'import/prefer-default-export': 'off',
|
|
39
43
|
'import/no-relative-packages': 'off',
|
|
40
44
|
'jsx-a11y/accessible-emoji': 0,
|
|
41
|
-
'object-curly-spacing': 2,
|
|
42
45
|
'prettier/prettier': 'error',
|
|
43
46
|
'react-hooks/exhaustive-deps': 'warn',
|
|
44
47
|
'react-hooks/rules-of-hooks': 'error',
|
|
45
48
|
'react/jsx-boolean-value': 0,
|
|
46
49
|
'react/jsx-filename-extension': [2, {
|
|
47
|
-
extensions: ['.js', '.jsx']
|
|
50
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
48
51
|
}],
|
|
49
52
|
'react/jsx-fragments': 0,
|
|
50
53
|
'react/jsx-props-no-spreading': 0,
|
|
51
54
|
'react/jsx-uses-react': 'off',
|
|
52
55
|
'react/react-in-jsx-scope': 'off',
|
|
53
|
-
semi: ['error', 'never']
|
|
56
|
+
semi: ['error', 'never'],
|
|
57
|
+
'import/extensions': ['error', 'ignorePackages', {
|
|
58
|
+
js: 'never',
|
|
59
|
+
jsx: 'never',
|
|
60
|
+
ts: 'never',
|
|
61
|
+
tsx: 'never'
|
|
62
|
+
}],
|
|
63
|
+
'@typescript-eslint/no-empty-function': 0,
|
|
64
|
+
'@typescript-eslint/strict-boolean-expressions': 0,
|
|
65
|
+
'@typescript-eslint/prefer-nullish-coalescing': 0,
|
|
66
|
+
'object-curly-spacing': 0,
|
|
67
|
+
'comma-dangle': 0,
|
|
68
|
+
'no-unused-vars': 0
|
|
54
69
|
},
|
|
55
70
|
settings: {
|
|
56
71
|
'import/resolver': {
|
|
57
72
|
alias: {
|
|
58
|
-
map: [['@
|
|
59
|
-
extensions: ['.js']
|
|
73
|
+
map: [['@papillonarts/components', '@papillonarts/components/build']],
|
|
74
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
60
75
|
},
|
|
61
76
|
node: {
|
|
62
|
-
extensions: ['.js', '.jsx']
|
|
77
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
63
78
|
}
|
|
64
79
|
},
|
|
65
80
|
react: {
|
package/jest/config.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getJestSetup = getJestSetup;
|
|
7
|
+
// https://jestjs.io/docs/getting-started#using-typescript
|
|
8
|
+
|
|
7
9
|
function getJestSetup(_ref) {
|
|
8
10
|
var testPathIgnorePatterns = _ref.testPathIgnorePatterns,
|
|
9
11
|
coverageDirectory = _ref.coverageDirectory,
|
|
@@ -11,11 +13,11 @@ function getJestSetup(_ref) {
|
|
|
11
13
|
collectCoverageFrom = _ref.collectCoverageFrom,
|
|
12
14
|
coverageThreshold = _ref.coverageThreshold;
|
|
13
15
|
return {
|
|
14
|
-
testMatch: ['**/?(*.)test.js?(x)'],
|
|
16
|
+
testMatch: ['**/?(*.)test.(js|ts)?(x)'],
|
|
15
17
|
testPathIgnorePatterns: testPathIgnorePatterns,
|
|
16
18
|
roots: ['<rootDir>'],
|
|
17
19
|
transform: {
|
|
18
|
-
'^.+\\.(js|jsx)$': 'babel-jest'
|
|
20
|
+
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest'
|
|
19
21
|
},
|
|
20
22
|
coverageDirectory: coverageDirectory,
|
|
21
23
|
collectCoverage: collectCoverage,
|
|
@@ -28,7 +30,7 @@ function getJestSetup(_ref) {
|
|
|
28
30
|
},
|
|
29
31
|
// https://jestjs.io/docs/tutorial-react-native#transformignorepatterns-customization
|
|
30
32
|
transformIgnorePatterns: ['node_modules/(?!((@)?uuid|parse5|jsdom/node_modules/parse5)/)'],
|
|
31
|
-
moduleFileExtensions: ['js', 'jsx'],
|
|
33
|
+
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
|
|
32
34
|
coverageThreshold: coverageThreshold
|
|
33
35
|
};
|
|
34
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papillonarts/setup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Papillon Arts Setup",
|
|
5
5
|
"homepage": "https://github.com/papillonarts/papillonarts/tree/master/packages/setup",
|
|
6
6
|
"repository": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"build-acceptance": "npm run build",
|
|
30
30
|
"build-release": "npm run build"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "584fbedfbea9771d584d15adb3396feb2e9c56b6"
|
|
33
33
|
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/* https://storybook.js.org/docs/configure/integration/typescript */
|
|
2
|
+
/* eslint-disable no-unused-vars */
|
|
3
|
+
/* eslint-disable no-param-reassign */
|
|
4
|
+
/* eslint-disable global-require */
|
|
5
|
+
import webpack from 'webpack'
|
|
6
|
+
import type { StorybookConfig } from '@storybook/react-webpack5'
|
|
7
|
+
import { isEmptyObject } from '@papillonarts/library/object'
|
|
8
|
+
// import { getBabelLoaderAdvancedSetup } from '@papillonarts/setup/webpack'
|
|
9
|
+
import { getBabelLoaderAdvancedSetup } from '../webpack'
|
|
10
|
+
|
|
11
|
+
export function getStorybookMainSetup({ storiesBasePath, includeBasePath, modulesBasePath, rootAttributesDefaults }): StorybookConfig {
|
|
12
|
+
// https://storybook.js.org/docs/react/api/main-config
|
|
13
|
+
return {
|
|
14
|
+
// https://storybook.js.org/docs/api/main-config/main-config-preview-body
|
|
15
|
+
previewBody: (body) => {
|
|
16
|
+
if (rootAttributesDefaults) {
|
|
17
|
+
// https://github.com/storybookjs/storybook/issues/24429
|
|
18
|
+
return `
|
|
19
|
+
${body}
|
|
20
|
+
<script type="text/javascript">
|
|
21
|
+
(() => {
|
|
22
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
23
|
+
const storybookRootElement = document.getElementById("storybook-root")
|
|
24
|
+
|
|
25
|
+
// https://primer.style/foundations/primitives/getting-started
|
|
26
|
+
storybookRootElement.setAttribute("data-color-mode", "light")
|
|
27
|
+
storybookRootElement.setAttribute("data-light-theme", "light")
|
|
28
|
+
storybookRootElement.setAttribute("data-dark-theme", "dark")
|
|
29
|
+
});
|
|
30
|
+
})()
|
|
31
|
+
</script>
|
|
32
|
+
`
|
|
33
|
+
}
|
|
34
|
+
return `${body}`
|
|
35
|
+
},
|
|
36
|
+
// https://storybook.js.org/docs/react/configure/frameworks
|
|
37
|
+
framework: {
|
|
38
|
+
name: '@storybook/react-webpack5',
|
|
39
|
+
options: {
|
|
40
|
+
fastRefresh: false,
|
|
41
|
+
strictMode: false,
|
|
42
|
+
legacyRootApi: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// https://storybook.js.org/docs/react/api/main-config-stories
|
|
47
|
+
stories: [storiesBasePath],
|
|
48
|
+
|
|
49
|
+
// https://storybook.js.org/docs/react/api/main-config-addons
|
|
50
|
+
// https://storybook.js.org/docs/react/addons/introduction
|
|
51
|
+
// https://storybook.js.org/integrations
|
|
52
|
+
addons: [
|
|
53
|
+
// https://storybook.js.org/addons/@storybook/addon-a11y
|
|
54
|
+
'@storybook/addon-a11y',
|
|
55
|
+
|
|
56
|
+
// included by default in @storybook/addon-essentials
|
|
57
|
+
// https://storybook.js.org/docs/react/essentials/actions
|
|
58
|
+
// https://storybook.js.org/addons/@storybook/addon-actions
|
|
59
|
+
// '@storybook/addon-actions',
|
|
60
|
+
|
|
61
|
+
// included by default in @storybook/addon-essentials
|
|
62
|
+
// https://storybook.js.org/docs/react/essentials/backgrounds
|
|
63
|
+
// https://storybook.js.org/addons/@storybook/addon-backgrounds
|
|
64
|
+
// '@storybook/addon-backgrounds',
|
|
65
|
+
|
|
66
|
+
// https://storybook.js.org/addons/chromatic
|
|
67
|
+
// chromatic
|
|
68
|
+
|
|
69
|
+
// included by default in @storybook/addon-essentials
|
|
70
|
+
// https://storybook.js.org/docs/react/essentials/controls
|
|
71
|
+
// https://storybook.js.org/addons/@storybook/addon-controls
|
|
72
|
+
// '@storybook/addon-controls',
|
|
73
|
+
|
|
74
|
+
// https://storybook.js.org/addons/storybook-addon-designs
|
|
75
|
+
// storybook-addon-designs
|
|
76
|
+
|
|
77
|
+
// included by default in @storybook/addon-essentials
|
|
78
|
+
// https://storybook.js.org/docs/react/essentials/docs (404)
|
|
79
|
+
// https://storybook.js.org/addons/@storybook/addon-docs
|
|
80
|
+
// {
|
|
81
|
+
// name: '@storybook/addon-docs',
|
|
82
|
+
// options: {
|
|
83
|
+
// jsxOptions: {},
|
|
84
|
+
// csfPluginOptions: null,
|
|
85
|
+
// mdxPluginOptions: {},
|
|
86
|
+
// transcludeMarkdown: true,
|
|
87
|
+
// },
|
|
88
|
+
// },
|
|
89
|
+
|
|
90
|
+
// https://storybook.js.org/docs/react/essentials/introduction
|
|
91
|
+
// https://storybook.js.org/integrations/tag/essentials
|
|
92
|
+
// '@storybook/addon-essentials',
|
|
93
|
+
|
|
94
|
+
// included by default in @storybook/addon-essentials
|
|
95
|
+
// https://storybook.js.org/docs/react/essentials/highlight (404)
|
|
96
|
+
// https://storybook.js.org/addons/@storybook/addon-highlight
|
|
97
|
+
// '@storybook/addon-highlight',
|
|
98
|
+
|
|
99
|
+
// https://storybook.js.org/addons/@storybook/addon-interactions
|
|
100
|
+
// '@storybook/addon-interactions',
|
|
101
|
+
|
|
102
|
+
// https://storybook.js.org/addons/@storybook/addon-jest
|
|
103
|
+
'@storybook/addon-jest',
|
|
104
|
+
|
|
105
|
+
// https://storybook.js.org/addons/@storybook/addon-links
|
|
106
|
+
'@storybook/addon-links',
|
|
107
|
+
|
|
108
|
+
// https://storybook.js.org/addons/msw-storybook-addon
|
|
109
|
+
// msw-storybook-addon
|
|
110
|
+
|
|
111
|
+
// included by default in @storybook/addon-essentials
|
|
112
|
+
// https://storybook.js.org/docs/react/essentials/measure-and-outline
|
|
113
|
+
// https://storybook.js.org/addons/@storybook/addon-measure
|
|
114
|
+
// https://storybook.js.org/addons/@storybook/addon-outline
|
|
115
|
+
// '@storybook/addon-measure',
|
|
116
|
+
// '@storybook/addon-outline',
|
|
117
|
+
|
|
118
|
+
// included by default in @storybook/addon-essentials
|
|
119
|
+
// https://storybook.js.org/docs/react/essentials/toolbars-and-globals
|
|
120
|
+
// https://storybook.js.org/addons/@storybook/addon-toolbars
|
|
121
|
+
// '@storybook/addon-toolbars',
|
|
122
|
+
|
|
123
|
+
// included by default in @storybook/addon-essentials
|
|
124
|
+
// https://storybook.js.org/docs/react/essentials/viewport
|
|
125
|
+
// https://storybook.js.org/addons/@storybook/addon-viewport
|
|
126
|
+
// '@storybook/addon-viewport',
|
|
127
|
+
|
|
128
|
+
'@chromatic-com/storybook',
|
|
129
|
+
|
|
130
|
+
// https://storybook.js.org/addons/@storybook/addon-styling-webpack
|
|
131
|
+
'@storybook/addon-styling-webpack',
|
|
132
|
+
|
|
133
|
+
// https://storybook.js.org/addons/@storybook/addon-themes
|
|
134
|
+
'@storybook/addon-themes',
|
|
135
|
+
|
|
136
|
+
'@storybook/addon-webpack5-compiler-babel',
|
|
137
|
+
],
|
|
138
|
+
|
|
139
|
+
// https://storybook.js.org/docs/react/api/main-config-babel
|
|
140
|
+
// ...
|
|
141
|
+
|
|
142
|
+
// https://storybook.js.org/docs/react/api/main-config-babel-default
|
|
143
|
+
// ...
|
|
144
|
+
|
|
145
|
+
// https://storybook.js.org/docs/react/api/main-config-core
|
|
146
|
+
// https://storybook.js.org/docs/api/main-config/main-config-core#builder
|
|
147
|
+
core: { builder: { name: '@storybook/builder-webpack5', options: null } },
|
|
148
|
+
|
|
149
|
+
// https://storybook.js.org/docs/react/api/main-config-docs
|
|
150
|
+
// https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
151
|
+
// https://storybook.js.org/docs/react/writing-docs/mdx
|
|
152
|
+
// https://storybook.js.org/docs/writing-docs/autodocs
|
|
153
|
+
docs: { defaultName: 'Documentation', docsMode: false },
|
|
154
|
+
|
|
155
|
+
// https://storybook.js.org/docs/react/api/main-config-env
|
|
156
|
+
// ...
|
|
157
|
+
|
|
158
|
+
// https://storybook.js.org/docs/react/api/main-config-features
|
|
159
|
+
// ...
|
|
160
|
+
|
|
161
|
+
// https://storybook.js.org/docs/react/api/main-config-log-level
|
|
162
|
+
logLevel: 'debug',
|
|
163
|
+
|
|
164
|
+
// https://storybook.js.org/docs/react/api/main-config-manager-head
|
|
165
|
+
// ...
|
|
166
|
+
|
|
167
|
+
// https://storybook.js.org/docs/react/api/main-config-preview-annotations
|
|
168
|
+
// ...
|
|
169
|
+
|
|
170
|
+
// https://storybook.js.org/docs/react/api/main-config-preview-body
|
|
171
|
+
// ...
|
|
172
|
+
|
|
173
|
+
// https://storybook.js.org/docs/react/api/main-config-preview-head
|
|
174
|
+
// ...
|
|
175
|
+
|
|
176
|
+
// https://storybook.js.org/docs/react/api/main-config-refs
|
|
177
|
+
// ...
|
|
178
|
+
|
|
179
|
+
// https://storybook.js.org/docs/react/api/main-config-static-dirs
|
|
180
|
+
// ...
|
|
181
|
+
|
|
182
|
+
// https://storybook.js.org/docs/react/api/main-config-typescript
|
|
183
|
+
// ...
|
|
184
|
+
|
|
185
|
+
// https://storybook.js.org/docs/react/api/main-config-webpack-final
|
|
186
|
+
webpackFinal: async (config, { configType }) => {
|
|
187
|
+
// @ts-ignore
|
|
188
|
+
const fileLoaderRuleSVG = config.module.rules.find((rule) => !isEmptyObject(rule) && rule.test.test?.('.svg'))
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
fileLoaderRuleSVG.exclude = /\.svg$/
|
|
191
|
+
|
|
192
|
+
config.module.rules = config.module.rules.concat([
|
|
193
|
+
{
|
|
194
|
+
test: /\.(css|scss)$/,
|
|
195
|
+
use: [
|
|
196
|
+
{
|
|
197
|
+
loader: 'style-loader',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
loader: 'css-loader',
|
|
201
|
+
options: {
|
|
202
|
+
importLoaders: 2,
|
|
203
|
+
sourceMap: true,
|
|
204
|
+
modules: {
|
|
205
|
+
localIdentName: '[name]__[local]___[hash:base64:5]',
|
|
206
|
+
/* https://webpack.js.org/loaders/css-loader/#exportlocalsconvention */
|
|
207
|
+
exportLocalsConvention: 'as-is',
|
|
208
|
+
},
|
|
209
|
+
/* https://stackoverflow.com/questions/78589664/style-loader-does-not-recoginize-default-imports-of-css-modules-in-storybooks */
|
|
210
|
+
esModule: false,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
loader: 'postcss-loader',
|
|
215
|
+
options: {
|
|
216
|
+
postcssOptions: {
|
|
217
|
+
sourceMap: true,
|
|
218
|
+
plugins: () => [require('postcss-preset-env')()],
|
|
219
|
+
parser: 'postcss-scss',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
loader: 'sass-loader',
|
|
225
|
+
options: {
|
|
226
|
+
sassOptions: {
|
|
227
|
+
includePaths: [modulesBasePath],
|
|
228
|
+
// https://sass-lang.com/documentation/js-api/interfaces/options/#quietDeps
|
|
229
|
+
// https://sass-lang.com/documentation/js-api/interfaces/options/#silenceDeprecations
|
|
230
|
+
// https://sass-lang.com/documentation/js-api/interfaces/deprecations/
|
|
231
|
+
quietDeps: true,
|
|
232
|
+
silenceDeprecations: ['import', 'global-builtin'],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
test: /\.svg$/i,
|
|
240
|
+
issuer: /\.[jt]sx?$/,
|
|
241
|
+
use: ['@svgr/webpack'],
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
test: /\.int.story\.mdx$/,
|
|
245
|
+
use: [
|
|
246
|
+
{
|
|
247
|
+
loader: 'babel-loader',
|
|
248
|
+
options: {
|
|
249
|
+
plugins: ['@babel/plugin-transform-react-jsx'],
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
loader: '@mdx-js/loader',
|
|
254
|
+
options: {},
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
getBabelLoaderAdvancedSetup(),
|
|
259
|
+
])
|
|
260
|
+
config.plugins.push(
|
|
261
|
+
new webpack.ProvidePlugin({
|
|
262
|
+
process: 'process/browser',
|
|
263
|
+
}),
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
config.resolve.fallback = {
|
|
267
|
+
...config.resolve.fallback,
|
|
268
|
+
tty: require.resolve('tty-browserify'),
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return config
|
|
272
|
+
},
|
|
273
|
+
typescript: {
|
|
274
|
+
reactDocgen: 'react-docgen-typescript',
|
|
275
|
+
check: true,
|
|
276
|
+
},
|
|
277
|
+
}
|
|
278
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
2
|
+
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks'
|
|
3
|
+
|
|
4
|
+
export function getStorybookPreviewSetup({ parameters: { a11y, decorators, docs } }) {
|
|
5
|
+
let parameters = {}
|
|
6
|
+
|
|
7
|
+
if (a11y) {
|
|
8
|
+
parameters = {
|
|
9
|
+
...parameters,
|
|
10
|
+
a11y: {
|
|
11
|
+
...{
|
|
12
|
+
// optional selector which element to inspect
|
|
13
|
+
// element: '#root',
|
|
14
|
+
// axe-core configurationOptions (https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#parameters-1)
|
|
15
|
+
config: {},
|
|
16
|
+
// axe-core optionsParameter (https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#options-parameter)
|
|
17
|
+
options: {},
|
|
18
|
+
// optional flag to prevent the automatic check
|
|
19
|
+
// manual: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (decorators) {
|
|
26
|
+
parameters = {
|
|
27
|
+
...parameters,
|
|
28
|
+
decorators: [
|
|
29
|
+
...[
|
|
30
|
+
(Story) => (
|
|
31
|
+
<MemoryRouter>
|
|
32
|
+
<Story />
|
|
33
|
+
</MemoryRouter>
|
|
34
|
+
),
|
|
35
|
+
],
|
|
36
|
+
],
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (docs) {
|
|
41
|
+
parameters = {
|
|
42
|
+
...parameters,
|
|
43
|
+
docs: {
|
|
44
|
+
...{ container: DocsContainer, page: DocsPage },
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { parameters }
|
|
50
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const coreJSVersion = '3.46.0'
|
|
2
|
+
|
|
3
|
+
export const targetBrowsers = {
|
|
4
|
+
production: ['> 1%', 'last 2 versions', 'Firefox ESR'],
|
|
5
|
+
legacyBrowsers: ['> 1%', 'last 2 versions', 'Firefox ESR'],
|
|
6
|
+
modernBrowsers: [
|
|
7
|
+
'last 2 Chrome versions',
|
|
8
|
+
'not Chrome < 60',
|
|
9
|
+
'last 2 Safari versions',
|
|
10
|
+
'not Safari < 10.1',
|
|
11
|
+
'last 2 iOS versions',
|
|
12
|
+
'not iOS < 10.3',
|
|
13
|
+
'last 2 Firefox versions',
|
|
14
|
+
'not Firefox < 54',
|
|
15
|
+
'last 2 Edge versions',
|
|
16
|
+
'not Edge < 15',
|
|
17
|
+
],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const manifestFileName = 'manifest.json'
|
|
21
|
+
|
|
22
|
+
export const indexHTMLName = 'index.html'
|
|
23
|
+
|
|
24
|
+
export const extensions = ['.js', '.jsx', '.json', '.scss']
|
package/webpack/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { getBabelLoaderAdvancedSetup } from './loader/babelLoader'
|
|
2
|
+
export { getCSSLoaderStandardSetup } from './loader/cssLoader'
|
|
3
|
+
export { getFontLoaderStandardSetup } from './loader/fontLoader'
|
|
4
|
+
export { getImageLoaderStandardSetup } from './loader/imageLoader'
|
|
5
|
+
export { getMarkdownLoaderStandardSetup } from './loader/markdownLoader'
|
|
6
|
+
export { getPostCSSLoaderStandardSetup } from './loader/postCSSLoader'
|
|
7
|
+
export { getSassLoaderStandardSetup } from './loader/sassLoader'
|
|
8
|
+
export { getSVGRLoaderStandardSetup, getSVGRLoaderAdvancedSetup } from './loader/svgrLoader'
|
|
9
|
+
export { getBannerPluginStandardSetup } from './plugin/bannerPlugin'
|
|
10
|
+
export { getCleanWebpackPluginStandardSetup, getCleanWebpackPluginAdvancedSetup } from './plugin/cleanWebpackPlugin'
|
|
11
|
+
export { getCopyWebpackPluginStandardSetup } from './plugin/copyWebpackPlugin'
|
|
12
|
+
export { getCSSMinimizerWebpackPluginStandardSetup } from './plugin/cssMinimizerWebpackPlugin'
|
|
13
|
+
export { getDotenvWebpackStandardSetup, getDotenvWebpackAdvancedSetup } from './plugin/dotenvWebpack'
|
|
14
|
+
export { getHotModuleReplacementPluginStandardSetup } from './plugin/hotModuleReplacementPlugin'
|
|
15
|
+
export { getHtmlWebpackPluginStandardSetup, getHtmlWebpackPluginAdvancedSetup } from './plugin/htmlWebpackPlugin'
|
|
16
|
+
export {
|
|
17
|
+
MiniCSSExtractPluginLoader,
|
|
18
|
+
getMiniCSSExtractPluginStandardSetup,
|
|
19
|
+
getMiniCSSExtractPluginAdvancedSetup,
|
|
20
|
+
} from './plugin/miniCSSExtractPlugin'
|
|
21
|
+
export { getModuleConcatenationPluginStandardSetup } from './plugin/moduleConcatenationPlugin'
|
|
22
|
+
export { getWebpackBundleAnalyzerStandardSetup } from './plugin/webpackBundleAnalyzer'
|
|
23
|
+
export { getWebpackManifestPluginStandardSetup } from './plugin/webpackManifestPlugin'
|
|
24
|
+
export { getDevServerStandardSetup } from './server/devServer'
|
|
25
|
+
export { getWebpackCommonSetup } from './setup/commonSetup'
|
|
26
|
+
export { getWebpackDevelopmentSetup } from './setup/developmentSetup'
|
|
27
|
+
export { getWebpackProductionSetup } from './setup/productionSetup'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// https://github.com/babel/babel-loader
|
|
2
|
+
|
|
3
|
+
import { coreJSVersion, targetBrowsers } from '../constant'
|
|
4
|
+
|
|
5
|
+
export function getBabelLoaderAdvancedSetup() {
|
|
6
|
+
return {
|
|
7
|
+
test: /\.(js|jsx)$/,
|
|
8
|
+
exclude: /node_modules/,
|
|
9
|
+
use: {
|
|
10
|
+
loader: 'babel-loader',
|
|
11
|
+
options: {
|
|
12
|
+
presets: [
|
|
13
|
+
[
|
|
14
|
+
'@babel/preset-env',
|
|
15
|
+
{
|
|
16
|
+
modules: false,
|
|
17
|
+
useBuiltIns: 'entry',
|
|
18
|
+
corejs: coreJSVersion,
|
|
19
|
+
targets: { browsers: Object.values(targetBrowsers.modernBrowsers) },
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
'@babel/preset-react',
|
|
23
|
+
'@babel/preset-typescript',
|
|
24
|
+
],
|
|
25
|
+
plugins: [
|
|
26
|
+
[
|
|
27
|
+
'@babel/plugin-transform-react-jsx',
|
|
28
|
+
{
|
|
29
|
+
runtime: 'automatic',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
'@babel/plugin-transform-runtime',
|
|
33
|
+
'syntax-async-functions',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// https://github.com/webpack-contrib/html-loader
|
|
2
|
+
// https://github.com/peerigon/markdown-loader
|
|
3
|
+
|
|
4
|
+
export function getMarkdownLoaderStandardSetup() {
|
|
5
|
+
return {
|
|
6
|
+
test: /\.md$/,
|
|
7
|
+
use: [
|
|
8
|
+
{
|
|
9
|
+
loader: 'html-loader',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
loader: 'markdown-loader',
|
|
13
|
+
options: {},
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// https://github.com/webpack-contrib/postcss-loader
|
|
2
|
+
|
|
3
|
+
export function getPostCSSLoaderStandardSetup() {
|
|
4
|
+
return {
|
|
5
|
+
loader: 'postcss-loader',
|
|
6
|
+
options: {
|
|
7
|
+
postcssOptions: {
|
|
8
|
+
sourceMap: true,
|
|
9
|
+
plugins: () => ['postcss-preset-env'],
|
|
10
|
+
parser: 'postcss-scss',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
}
|