@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.
Files changed (61) hide show
  1. package/babel/index.js +1 -1
  2. package/eslint/index.js +25 -10
  3. package/jest/config.js +5 -3
  4. package/package.json +2 -2
  5. package/storybook/index.ts +3 -0
  6. package/storybook/mainSetup.ts +278 -0
  7. package/storybook/managerSetup.ts +9 -0
  8. package/storybook/previewSetup.tsx +50 -0
  9. package/webpack/constant/index.ts +24 -0
  10. package/webpack/index.ts +27 -0
  11. package/webpack/loader/babelLoader.ts +38 -0
  12. package/webpack/loader/cssLoader.ts +13 -0
  13. package/webpack/loader/fontLoader.ts +8 -0
  14. package/webpack/loader/imageLoader.ts +8 -0
  15. package/webpack/loader/markdownLoader.ts +17 -0
  16. package/webpack/loader/postCSSLoader.ts +14 -0
  17. package/webpack/loader/{sassLoader.js → sassLoader.ts} +7 -14
  18. package/webpack/loader/svgrLoader.ts +17 -0
  19. package/webpack/plugin/bannerPlugin.ts +18 -0
  20. package/webpack/plugin/cleanWebpackPlugin.ts +27 -0
  21. package/webpack/plugin/copyWebpackPlugin.ts +18 -0
  22. package/webpack/plugin/cssMinimizerWebpackPlugin.ts +7 -0
  23. package/webpack/plugin/dotenvWebpack.ts +19 -0
  24. package/webpack/plugin/hotModuleReplacementPlugin.ts +7 -0
  25. package/webpack/plugin/htmlWebpackPlugin.ts +25 -0
  26. package/webpack/plugin/miniCSSExtractPlugin.ts +16 -0
  27. package/webpack/plugin/moduleConcatenationPlugin.ts +7 -0
  28. package/webpack/plugin/webpackBundleAnalyzer.ts +7 -0
  29. package/webpack/plugin/webpackManifestPlugin.ts +15 -0
  30. package/webpack/server/devServer.ts +13 -0
  31. package/webpack/setup/commonSetup.ts +36 -0
  32. package/webpack/setup/developmentSetup.ts +52 -0
  33. package/webpack/setup/productionSetup.ts +66 -0
  34. package/storybook/index.js +0 -26
  35. package/storybook/mainSetup.js +0 -265
  36. package/storybook/managerSetup.js +0 -16
  37. package/storybook/previewSetup.js +0 -54
  38. package/webpack/constant/index.js +0 -15
  39. package/webpack/index.js +0 -202
  40. package/webpack/loader/babelLoader.js +0 -31
  41. package/webpack/loader/cssLoader.js +0 -22
  42. package/webpack/loader/fontLoader.js +0 -14
  43. package/webpack/loader/imageLoader.js +0 -14
  44. package/webpack/loader/markdownLoader.js +0 -20
  45. package/webpack/loader/postCSSLoader.js +0 -22
  46. package/webpack/loader/svgrLoader.js +0 -25
  47. package/webpack/plugin/bannerPlugin.js +0 -16
  48. package/webpack/plugin/cleanWebpackPlugin.js +0 -31
  49. package/webpack/plugin/copyWebpackPlugin.js +0 -24
  50. package/webpack/plugin/cssMinimizerWebpackPlugin.js +0 -13
  51. package/webpack/plugin/dotenvWebpack.js +0 -35
  52. package/webpack/plugin/hotModuleReplacementPlugin.js +0 -13
  53. package/webpack/plugin/htmlWebpackPlugin.js +0 -42
  54. package/webpack/plugin/miniCSSExtractPlugin.js +0 -22
  55. package/webpack/plugin/moduleConcatenationPlugin.js +0 -13
  56. package/webpack/plugin/webpackBundleAnalyzer.js +0 -15
  57. package/webpack/plugin/webpackManifestPlugin.js +0 -21
  58. package/webpack/server/devServer.js +0 -21
  59. package/webpack/setup/commonSetup.js +0 -37
  60. package/webpack/setup/developmentSetup.js +0 -54
  61. package/webpack/setup/productionSetup.js +0 -59
@@ -1,25 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSassLoaderStandardSetup = getSassLoaderStandardSetup;
7
1
  // https://github.com/webpack-contrib/sass-loader
8
2
 
9
- function getSassLoaderStandardSetup(_ref) {
10
- var includePaths = _ref.includePaths;
3
+ export function getSassLoaderStandardSetup({ includePaths }) {
11
4
  return {
12
5
  loader: 'sass-loader',
13
6
  options: {
14
7
  sassOptions: {
15
8
  indentWidth: 4,
16
- includePaths: includePaths,
9
+ includePaths,
17
10
  // https://sass-lang.com/documentation/js-api/interfaces/options/#quietDeps
18
11
  // https://sass-lang.com/documentation/js-api/interfaces/options/#silenceDeprecations
19
12
  // https://sass-lang.com/documentation/js-api/interfaces/deprecations/
20
13
  quietDeps: true,
21
- silenceDeprecations: ['import', 'global-builtin']
22
- }
23
- }
24
- };
25
- }
14
+ silenceDeprecations: ['import', 'global-builtin'],
15
+ },
16
+ },
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ // https://github.com/gregberge/svgr/tree/main/packages/webpack
2
+
3
+ export function getSVGRLoaderStandardSetup() {
4
+ return {
5
+ test: /\.svg$/,
6
+ use: ['@svgr/webpack'],
7
+ }
8
+ }
9
+
10
+ export function getSVGRLoaderAdvancedSetup() {
11
+ return {
12
+ test: /\.svg$/i,
13
+ issuer: /\.[jt]sx?$/,
14
+ resourceQuery: { not: [/url/] },
15
+ use: ['@svgr/webpack'],
16
+ }
17
+ }
@@ -0,0 +1,18 @@
1
+ // https://webpack.js.org/plugins/banner-plugin/
2
+
3
+ import webpack from 'webpack'
4
+
5
+ export function getBannerPluginStandardSetup(packageJSON) {
6
+ return new webpack.BannerPlugin({
7
+ banner: [
8
+ '/*!',
9
+ ` * @project ${packageJSON.name}`,
10
+ ' * @name [filebase]',
11
+ ` * @author ${packageJSON.author.name}`,
12
+ ` * @copyright Copyright (c) ${new Date().getFullYear()} ${packageJSON.author.name}`,
13
+ ' */',
14
+ '',
15
+ ].join('\n'),
16
+ raw: true,
17
+ })
18
+ }
@@ -0,0 +1,27 @@
1
+ // https://github.com/johnagan/clean-webpack-plugin
2
+
3
+ import { CleanWebpackPlugin } from 'clean-webpack-plugin'
4
+
5
+ export function getCleanWebpackPluginStandardSetup() {
6
+ return new CleanWebpackPlugin()
7
+ }
8
+
9
+ export function getCleanWebpackPluginAdvancedSetup({
10
+ dry,
11
+ verbose,
12
+ cleanStaleWebpackAssets,
13
+ protectWebpackAssets,
14
+ cleanOnceBeforeBuildPatterns,
15
+ cleanAfterEveryBuildPatterns,
16
+ dangerouslyAllowCleanPatternsOutsideProject,
17
+ }) {
18
+ return new CleanWebpackPlugin({
19
+ dry,
20
+ verbose,
21
+ cleanStaleWebpackAssets,
22
+ protectWebpackAssets,
23
+ cleanOnceBeforeBuildPatterns,
24
+ cleanAfterEveryBuildPatterns,
25
+ dangerouslyAllowCleanPatternsOutsideProject,
26
+ })
27
+ }
@@ -0,0 +1,18 @@
1
+ // https://github.com/webpack-contrib/copy-webpack-plugin
2
+
3
+ import CopyWebpackPlugin from 'copy-webpack-plugin'
4
+
5
+ export function getCopyWebpackPluginStandardSetup({ from, to }) {
6
+ return new CopyWebpackPlugin({
7
+ patterns: [
8
+ {
9
+ from,
10
+ to,
11
+ globOptions: {
12
+ ignore: ['*.DS_Store'],
13
+ },
14
+ noErrorOnMissing: true,
15
+ },
16
+ ],
17
+ })
18
+ }
@@ -0,0 +1,7 @@
1
+ // https://github.com/webpack-contrib/css-minimizer-webpack-plugin
2
+
3
+ import CSSMinimizerWebpackPlugin from 'css-minimizer-webpack-plugin'
4
+
5
+ export function getCSSMinimizerWebpackPluginStandardSetup() {
6
+ return new CSSMinimizerWebpackPlugin()
7
+ }
@@ -0,0 +1,19 @@
1
+ // https://github.com/mrsteele/dotenv-webpack
2
+
3
+ import DotenvWebpack from 'dotenv-webpack'
4
+
5
+ export function getDotenvWebpackStandardSetup({ path }) {
6
+ return new DotenvWebpack({ path })
7
+ }
8
+
9
+ export function getDotenvWebpackAdvancedSetup({ path, safe, allowEmptyValues, systemvars, silent, defaults, prefix }) {
10
+ return new DotenvWebpack({
11
+ path,
12
+ safe,
13
+ allowEmptyValues,
14
+ systemvars,
15
+ silent,
16
+ defaults,
17
+ prefix,
18
+ })
19
+ }
@@ -0,0 +1,7 @@
1
+ // https://webpack.js.org/plugins/hot-module-replacement-plugin/
2
+
3
+ import webpack from 'webpack'
4
+
5
+ export function getHotModuleReplacementPluginStandardSetup() {
6
+ return new webpack.HotModuleReplacementPlugin()
7
+ }
@@ -0,0 +1,25 @@
1
+ // https://github.com/jantimon/html-webpack-plugin
2
+
3
+ import HtmlWebpackPlugin from 'html-webpack-plugin'
4
+ import { indexHTMLName } from '../constant'
5
+
6
+ export function getHtmlWebpackPluginStandardSetup({ title, micrositeWebpackFolderPath }) {
7
+ return new HtmlWebpackPlugin({
8
+ title,
9
+ meta: { viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no' },
10
+ template: `${micrositeWebpackFolderPath}/${indexHTMLName}`,
11
+ filename: indexHTMLName,
12
+ inject: 'body',
13
+ scriptLoading: 'defer',
14
+ })
15
+ }
16
+ export function getHtmlWebpackPluginAdvancedSetup({ title, meta, template, filename, inject, scriptLoading }) {
17
+ return new HtmlWebpackPlugin({
18
+ title,
19
+ meta,
20
+ template,
21
+ filename,
22
+ inject,
23
+ scriptLoading,
24
+ })
25
+ }
@@ -0,0 +1,16 @@
1
+ // https://github.com/webpack-contrib/mini-css-extract-plugin
2
+
3
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin'
4
+
5
+ export const MiniCSSExtractPluginLoader = MiniCssExtractPlugin.loader
6
+
7
+ export function getMiniCSSExtractPluginStandardSetup() {
8
+ return new MiniCssExtractPlugin()
9
+ }
10
+
11
+ export function getMiniCSSExtractPluginAdvancedSetup() {
12
+ return new MiniCssExtractPlugin({
13
+ filename: 'styles/[name].[contenthash].css',
14
+ chunkFilename: '[id].css',
15
+ })
16
+ }
@@ -0,0 +1,7 @@
1
+ // https://webpack.js.org/plugins/module-concatenation-plugin/
2
+
3
+ import webpack from 'webpack'
4
+
5
+ export function getModuleConcatenationPluginStandardSetup() {
6
+ return new webpack.optimize.ModuleConcatenationPlugin()
7
+ }
@@ -0,0 +1,7 @@
1
+ // https://github.com/webpack-contrib/webpack-bundle-analyzer
2
+
3
+ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
4
+
5
+ export function getWebpackBundleAnalyzerStandardSetup() {
6
+ return new BundleAnalyzerPlugin({ analyzerMode: 'static', openAnalyzer: false })
7
+ }
@@ -0,0 +1,15 @@
1
+ // https://github.com/shellscape/webpack-manifest-plugin
2
+ /* eslint-disable no-param-reassign */
3
+ import { WebpackManifestPlugin } from 'webpack-manifest-plugin'
4
+ import { manifestFileName } from '../constant'
5
+
6
+ export function getWebpackManifestPluginStandardSetup() {
7
+ return new WebpackManifestPlugin({
8
+ fileName: manifestFileName,
9
+ basePath: '',
10
+ map: (file) => {
11
+ file.name = file.name.replace(/(\.[a-f0-9]{32})(\..*)$/, '$2')
12
+ return file
13
+ },
14
+ })
15
+ }
@@ -0,0 +1,13 @@
1
+ // https://webpack.js.org/configuration/dev-server/
2
+
3
+ export function getDevServerStandardSetup() {
4
+ return {
5
+ historyApiFallback: true,
6
+ open: true,
7
+ compress: true,
8
+ hot: true,
9
+ port: 8080,
10
+ host: 'localhost',
11
+ headers: { 'Access-Control-Allow-Origin': '*' },
12
+ }
13
+ }
@@ -0,0 +1,36 @@
1
+ import { getBabelLoaderAdvancedSetup } from '../loader/babelLoader'
2
+ import { getFontLoaderStandardSetup } from '../loader/fontLoader'
3
+ import { getImageLoaderStandardSetup } from '../loader/imageLoader'
4
+ import { getSVGRLoaderAdvancedSetup } from '../loader/svgrLoader'
5
+ import { getMarkdownLoaderStandardSetup } from '../loader/markdownLoader'
6
+ import { getCleanWebpackPluginStandardSetup } from '../plugin/cleanWebpackPlugin'
7
+ import { getCopyWebpackPluginStandardSetup } from '../plugin/copyWebpackPlugin'
8
+ import { getHtmlWebpackPluginStandardSetup } from '../plugin/htmlWebpackPlugin'
9
+ import { getWebpackManifestPluginStandardSetup } from '../plugin/webpackManifestPlugin'
10
+ import { extensions } from '../constant'
11
+
12
+ export function getWebpackCommonSetup({ micrositeFolderPaths, packageJSON }) {
13
+ return {
14
+ entry: [`${micrositeFolderPaths.src}/index.js`],
15
+ plugins: [
16
+ getCleanWebpackPluginStandardSetup(),
17
+ getCopyWebpackPluginStandardSetup({ from: micrositeFolderPaths.public, to: 'assets' }),
18
+ getHtmlWebpackPluginStandardSetup({ title: packageJSON.description, micrositeWebpackFolderPath: micrositeFolderPaths.webpack }),
19
+ getWebpackManifestPluginStandardSetup(),
20
+ ],
21
+ module: {
22
+ rules: [
23
+ getBabelLoaderAdvancedSetup(),
24
+ getFontLoaderStandardSetup(),
25
+ getImageLoaderStandardSetup(),
26
+ getMarkdownLoaderStandardSetup(),
27
+ getSVGRLoaderAdvancedSetup(),
28
+ ],
29
+ },
30
+
31
+ resolve: {
32
+ modules: [micrositeFolderPaths.src, micrositeFolderPaths.nodeModules],
33
+ extensions,
34
+ },
35
+ }
36
+ }
@@ -0,0 +1,52 @@
1
+ import { merge } from 'webpack-merge'
2
+ import { getCSSLoaderStandardSetup } from '../loader/cssLoader'
3
+ import { getPostCSSLoaderStandardSetup } from '../loader/postCSSLoader'
4
+ import { getSassLoaderStandardSetup } from '../loader/sassLoader'
5
+ import { getDotenvWebpackStandardSetup } from '../plugin/dotenvWebpack'
6
+ import { getHotModuleReplacementPluginStandardSetup } from '../plugin/hotModuleReplacementPlugin'
7
+ import { getDevServerStandardSetup } from '../server/devServer'
8
+
9
+ export function getWebpackDevelopmentSetup({
10
+ webpackCommonSetup,
11
+ environmentVariablesFilePath,
12
+ micrositeUrlPath,
13
+ micrositeFolderPaths,
14
+ includedSourceFilePaths,
15
+ }) {
16
+ return merge([
17
+ webpackCommonSetup,
18
+ {
19
+ mode: 'development',
20
+ devtool: 'inline-source-map',
21
+ devServer: getDevServerStandardSetup(),
22
+ output: { path: micrositeFolderPaths.build, publicPath: micrositeUrlPath, filename: '[name].bundle.js' },
23
+ optimization: {
24
+ concatenateModules: true,
25
+ },
26
+ plugins: [getDotenvWebpackStandardSetup({ path: environmentVariablesFilePath }), getHotModuleReplacementPluginStandardSetup()],
27
+ module: {
28
+ rules: [
29
+ {
30
+ test: /\.s[ac]ss$/i,
31
+ include: includedSourceFilePaths,
32
+ use: [
33
+ 'style-loader',
34
+ getCSSLoaderStandardSetup({
35
+ sourceMap: false,
36
+ modules: {
37
+ localIdentName: '[name]_[local]_[hash:base64:5]',
38
+ /* https://webpack.js.org/loaders/css-loader/#exportlocalsconvention */
39
+ exportLocalsConvention: 'as-is',
40
+ },
41
+ /* https://stackoverflow.com/questions/78589664/style-loader-does-not-recoginize-default-imports-of-css-modules-in-storybooks */
42
+ esModule: false,
43
+ }),
44
+ getPostCSSLoaderStandardSetup(),
45
+ getSassLoaderStandardSetup({ includePaths: includedSourceFilePaths }),
46
+ ],
47
+ },
48
+ ],
49
+ },
50
+ },
51
+ ])
52
+ }
@@ -0,0 +1,66 @@
1
+ import { merge } from 'webpack-merge'
2
+ import { getCSSLoaderStandardSetup } from '../loader/cssLoader'
3
+ import { getBannerPluginStandardSetup } from '../plugin/bannerPlugin'
4
+ import { getCSSMinimizerWebpackPluginStandardSetup } from '../plugin/cssMinimizerWebpackPlugin'
5
+ import { getDotenvWebpackStandardSetup } from '../plugin/dotenvWebpack'
6
+ import { MiniCSSExtractPluginLoader, getMiniCSSExtractPluginAdvancedSetup } from '../plugin/miniCSSExtractPlugin'
7
+ import { getWebpackBundleAnalyzerStandardSetup } from '../plugin/webpackBundleAnalyzer'
8
+
9
+ export function getWebpackProductionSetup({
10
+ webpackCommonSetup,
11
+ environmentVariablesFilePath,
12
+ micrositeUrlPath,
13
+ micrositeFolderPaths,
14
+ packageJSON,
15
+ }) {
16
+ return merge([
17
+ webpackCommonSetup,
18
+ {
19
+ mode: 'production',
20
+ devtool: false,
21
+ output: {
22
+ path: micrositeFolderPaths.build,
23
+ publicPath: micrositeUrlPath,
24
+ filename: 'js/[name].[contenthash].bundle.js',
25
+ },
26
+ performance: {
27
+ hints: false,
28
+ maxEntrypointSize: 512000,
29
+ maxAssetSize: 512000,
30
+ },
31
+ optimization: {
32
+ minimize: true,
33
+ minimizer: [getCSSMinimizerWebpackPluginStandardSetup(), '...'],
34
+ runtimeChunk: { name: 'runtime' },
35
+ },
36
+ plugins: [
37
+ getBannerPluginStandardSetup(packageJSON),
38
+ getDotenvWebpackStandardSetup({ path: environmentVariablesFilePath }),
39
+ getMiniCSSExtractPluginAdvancedSetup(),
40
+ getWebpackBundleAnalyzerStandardSetup(),
41
+ ],
42
+ module: {
43
+ rules: [
44
+ {
45
+ test: /\.(sass|scss|css)$/,
46
+ use: [
47
+ MiniCSSExtractPluginLoader,
48
+ getCSSLoaderStandardSetup({
49
+ sourceMap: false,
50
+ modules: {
51
+ localIdentName: '[name]_[local]_[hash:base64:5]',
52
+ /* https://webpack.js.org/loaders/css-loader/#exportlocalsconvention */
53
+ exportLocalsConvention: 'as-is',
54
+ },
55
+ /* https://stackoverflow.com/questions/78589664/style-loader-does-not-recoginize-default-imports-of-css-modules-in-storybooks */
56
+ esModule: false,
57
+ }),
58
+ 'postcss-loader',
59
+ 'sass-loader',
60
+ ],
61
+ },
62
+ ],
63
+ },
64
+ },
65
+ ])
66
+ }
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "getStorybookMainSetup", {
7
- enumerable: true,
8
- get: function get() {
9
- return _mainSetup.getStorybookMainSetup;
10
- }
11
- });
12
- Object.defineProperty(exports, "getStorybookPreviewSetup", {
13
- enumerable: true,
14
- get: function get() {
15
- return _previewSetup.getStorybookPreviewSetup;
16
- }
17
- });
18
- Object.defineProperty(exports, "setStorybookManagerSetup", {
19
- enumerable: true,
20
- get: function get() {
21
- return _managerSetup.setStorybookManagerSetup;
22
- }
23
- });
24
- var _mainSetup = require("./mainSetup");
25
- var _managerSetup = require("./managerSetup");
26
- var _previewSetup = require("./previewSetup");