@emulsify/core 0.0.0-development → 1.1.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.
Files changed (54) hide show
  1. package/.github/workflows/addtoprojects.yml +1 -1
  2. package/.github/workflows/contributors.yml +1 -1
  3. package/.history/.github/workflows/addtoprojects_20240130164835.yml +21 -0
  4. package/.history/.github/workflows/addtoprojects_20240607213528.yml +21 -0
  5. package/.history/.github/workflows/contributors_20240130164835.yml +23 -0
  6. package/.history/.github/workflows/contributors_20240607213836.yml +23 -0
  7. package/.history/.storybook/main_20240401184129.js +22 -0
  8. package/.history/.storybook/main_20240607162805.js +22 -0
  9. package/.history/.storybook/main_20240610082738.js +22 -0
  10. package/.history/.storybook/manager_20240311205454.js +15 -0
  11. package/.history/.storybook/manager_20240607162817.js +15 -0
  12. package/.history/.storybook/preview_20240401184023.js +40 -0
  13. package/.history/.storybook/preview_20240607162826.js +40 -0
  14. package/.history/.storybook/preview_20240610083720.js +37 -0
  15. package/.history/.storybook/preview_20240610083852.js +30 -0
  16. package/.history/.storybook/setupTwig.test_20240228163244.js +33 -0
  17. package/.history/.storybook/setupTwig.test_20240607163045.js +33 -0
  18. package/.history/.storybook/setupTwig_20240326081425.js +59 -0
  19. package/.history/.storybook/setupTwig_20240607163001.js +43 -0
  20. package/.history/.storybook/setupTwig_20240607163019.js +43 -0
  21. package/.history/README_20240312154948.md +72 -0
  22. package/.history/README_20240607162731.md +94 -0
  23. package/.history/config/a11y.config_20240607110020.js +61 -0
  24. package/.history/config/a11y.config_20240607163052.js +61 -0
  25. package/.history/config/a11y.config_20240607163120.js +61 -0
  26. package/.history/config/webpack/css/style_20240228152007.js +1 -0
  27. package/.history/config/webpack/css/style_20240607163238.js +1 -0
  28. package/.history/config/webpack/css_20240317194751.js +1 -0
  29. package/.history/config/webpack/css_20240607163108.js +1 -0
  30. package/.history/config/webpack/css_20240607163132.js +1 -0
  31. package/.history/config/webpack/loaders_20240401184511.js +87 -0
  32. package/.history/config/webpack/loaders_20240610084138.js +87 -0
  33. package/.history/config/webpack/plugins_20240401184104.js +48 -0
  34. package/.history/config/webpack/plugins_20240607163148.js +48 -0
  35. package/.history/config/webpack/svgSprite_20240401184053.js +5 -0
  36. package/.history/config/webpack/svgSprite_20240607163207.js +5 -0
  37. package/.history/config/webpack/webpack.common_20240607090919.js +72 -0
  38. package/.history/config/webpack/webpack.common_20240607163224.js +72 -0
  39. package/.history/package_20240607155640.json +136 -0
  40. package/.history/package_20240607163353.json +135 -0
  41. package/.storybook/main.js +6 -6
  42. package/.storybook/manager.js +1 -1
  43. package/.storybook/preview.js +2 -12
  44. package/.storybook/setupTwig.js +5 -21
  45. package/.storybook/setupTwig.test.js +5 -5
  46. package/README.md +31 -9
  47. package/config/a11y.config.js +1 -1
  48. package/config/webpack/css/style.js +1 -1
  49. package/config/webpack/css.js +1 -1
  50. package/config/webpack/loaders.js +2 -2
  51. package/config/webpack/plugins.js +1 -1
  52. package/config/webpack/svgSprite.js +1 -1
  53. package/config/webpack/webpack.common.js +2 -2
  54. package/package.json +5 -6
@@ -0,0 +1,94 @@
1
+ ![Emulsify Core Design System](https://github.com/emulsify-ds/.github/blob/6bd435be881bd820bddfa05d88905efe29176a0a/assets/images/header.png)
2
+
3
+ # Emulsify Core
4
+
5
+ An open-source toolset for creating and implementing design systems.
6
+
7
+ **Emulsify Core** provides a [Storybook](https://storybook.js.org/) component library and a [Webpack](https://webpack.js.org/) development environment. It is meant to make project setup and ongoing development easier by bundling all necessary configuration and providing it as an extendable package for your theme or standalone project.
8
+
9
+ ## Installation and usage
10
+ Installation and configuration is setup by the provided base theme project(s). As of this writing, Emulsify Drupal is the only base theme project [with this integration](https://github.com/emulsify-ds/emulsify-drupal/blob/main/whisk/package.json#L36).
11
+
12
+ ### Manual installation
13
+ - `npm install @emulsify/core` within your repository or project theme.
14
+ - Copy the provided `npm run` scripts from [Emulsify Drupal's package.json](https://github.com/emulsify-ds/emulsify-drupal/blob/main/whisk/package.json#L15)
15
+ - Copy the contents of `whisk/config/emulsify-core/` from [Emulsify Drupal](https://github.com/emulsify-ds/emulsify-drupal/tree/main/whisk/config/emulsify-core) into your project so `config/` exists at the root of your repository or project theme. The files within `config/` allow you to extend or overwrite configuration provided by Emulsify Core.
16
+
17
+ ### Common Scripts
18
+
19
+ Run `nvm use` prior to running any of the following commands to verify you are using Node 20.
20
+ (Each is prefixed with `npm run `)
21
+
22
+ **develop**
23
+ Starts and instance of storybook, watches for any files changes, recompiles CSS/JS, and live reloads storybook assets.
24
+
25
+ **lint**
26
+ Lints all JS/SCSS within your components and reports any violations.
27
+
28
+ **lint-fix**
29
+ Automatically fixes any simple violations.
30
+
31
+ **prettier**
32
+ Outputs any code formatting violations.
33
+
34
+ **prettier-fix**
35
+ Automatically fixes any simple code formatting violations.
36
+
37
+ **storybook-build**
38
+ Builds a static output of the storybook instance.
39
+
40
+
41
+ ### Quick Links
42
+
43
+ - [Emulsify Homepage](https://www.emulsify.info/)
44
+
45
+ ## Demo
46
+
47
+ 1. [Storybook](http://storybook.emulsify.info/)
48
+
49
+ ## Contributing
50
+
51
+ ### [Code of Conduct](https://github.com/emulsify-ds/emulsify-drupal/blob/master/CODE_OF_CONDUCT.md)
52
+
53
+ The project maintainers have adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.
54
+
55
+ ### Contribution Guide
56
+
57
+ Please also follow the issue template and pull request templates provided. See below for the correct places to post issues:
58
+
59
+ 1. [Emulsify Drupal](https://github.com/emulsify-ds/emulsify-drupal/issues)
60
+ 2. [Emulsify Twig Extensions](https://github.com/emulsify-ds/emulsify-twig-extensions/issues)
61
+ 3. [Emulsify Tools (Drupal module)](https://www.drupal.org/project/issues/emulsify_tools)
62
+
63
+ ### Committing Changes
64
+
65
+ To facilitate automatic semantic release versioning, we utilize the [Conventional Changelog](https://github.com/conventional-changelog/conventional-changelog) standard through Commitizen. Follow these steps when commiting your work to ensure semantic release can version correctly.
66
+
67
+ 1. Stage your changes, ensuring they encompass exactly what you wish to change, no more.
68
+ 2. Run the `commit` script via `yarn commit` or `npm run commit` and follow the prompts to craft the perfect commit message.
69
+ 3. Your commit message will be used to create the changelog for the next version that includes that commit.
70
+
71
+ ## Author
72
+
73
+ Emulsify® is a product of [Four Kitchens](https://fourkitchens.com).
74
+
75
+ ### Contributors
76
+
77
+ <table>
78
+ <tr>
79
+ <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
80
+ <a href=https://github.com/callinmullaney>
81
+ <img src=https://avatars.githubusercontent.com/u/369018?v=4 width="100;" style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Callin Mullaney/>
82
+ <br />
83
+ <sub style="font-size:14px"><b>Callin Mullaney</b></sub>
84
+ </a>
85
+ </td>
86
+ <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
87
+ <a href=https://github.com/amazingrando>
88
+ <img src=https://avatars.githubusercontent.com/u/409903?v=4 width="100;" style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Randy Oest/>
89
+ <br />
90
+ <sub style="font-size:14px"><b>Randy Oest</b></sub>
91
+ </a>
92
+ </td>
93
+ </tr>
94
+ </table>
@@ -0,0 +1,61 @@
1
+ module.exports = {
2
+ storybookBuildDir: '../../../.out',
3
+ pa11y: {
4
+ includeNotices: false,
5
+ includeWarnings: false,
6
+ runners: ['axe'],
7
+ },
8
+ // A11y linting is done on a component-by-component
9
+ // basis, which results in the linter reporting some errors that
10
+ // should be ignored. These codes and descriptions allow for those
11
+ // errors to be targeted specifically.
12
+ ignore: {
13
+ codes: ['landmark-one-main', 'page-has-heading-one'],
14
+ descriptions: ['Ensures all page content is contained by landmarks'],
15
+ },
16
+ // List of storybook component IDs defined and used in this project.
17
+ components: [
18
+ 'base-colors--palettes',
19
+ 'base-motion--usage',
20
+ 'atoms-button--twig',
21
+ 'atoms-button--twig-alt',
22
+ 'atoms-forms--checkboxes',
23
+ 'atoms-forms--radio-buttons',
24
+ 'atoms-forms--select-dropdowns',
25
+ 'atoms-forms--textfields-examples',
26
+ 'atoms-images--images',
27
+ 'atoms-images--figures',
28
+ 'atoms-images--icons',
29
+ 'atoms-links--links',
30
+ 'atoms-lists--definition-list',
31
+ 'atoms-lists--unordered-list',
32
+ 'atoms-lists--ordered-list',
33
+ 'atoms-tables--table',
34
+ 'atoms-text--headings-examples',
35
+ 'atoms-text--blockquote-example',
36
+ 'atoms-text--preformatted',
37
+ 'atoms-text--random',
38
+ 'atoms-videos--wide',
39
+ 'atoms-videos--full',
40
+ 'molecules-cards--card-example',
41
+ 'molecules-cards--card-with-background',
42
+ 'molecules-cta--cta-example',
43
+ 'molecules-menus--breadcrumbs',
44
+ 'molecules-menus--inline',
45
+ 'molecules-menus--main',
46
+ 'molecules-menus--social',
47
+ 'molecules-menus-pager--pager-example',
48
+ 'molecules-status--status-examples',
49
+ 'molecules-tabs--js-tabs',
50
+ 'organisms-grids--default-grid',
51
+ 'organisms-grids--card-grid',
52
+ 'organisms-grids--cta-grid',
53
+ 'organisms-site--footer',
54
+ 'organisms-site--header',
55
+ 'templates-layouts--full-width',
56
+ 'templates-layouts--with-sidebar',
57
+ 'templates-place-holder--place-holder',
58
+ 'pages-content-types--article',
59
+ 'pages-landing-pages--home',
60
+ ],
61
+ };
@@ -0,0 +1,61 @@
1
+ module.exports = {
2
+ storybookBuildDir: '../../../../.out',
3
+ pa11y: {
4
+ includeNotices: false,
5
+ includeWarnings: false,
6
+ runners: ['axe'],
7
+ },
8
+ // A11y linting is done on a component-by-component
9
+ // basis, which results in the linter reporting some errors that
10
+ // should be ignored. These codes and descriptions allow for those
11
+ // errors to be targeted specifically.
12
+ ignore: {
13
+ codes: ['landmark-one-main', 'page-has-heading-one'],
14
+ descriptions: ['Ensures all page content is contained by landmarks'],
15
+ },
16
+ // List of storybook component IDs defined and used in this project.
17
+ components: [
18
+ 'base-colors--palettes',
19
+ 'base-motion--usage',
20
+ 'atoms-button--twig',
21
+ 'atoms-button--twig-alt',
22
+ 'atoms-forms--checkboxes',
23
+ 'atoms-forms--radio-buttons',
24
+ 'atoms-forms--select-dropdowns',
25
+ 'atoms-forms--textfields-examples',
26
+ 'atoms-images--images',
27
+ 'atoms-images--figures',
28
+ 'atoms-images--icons',
29
+ 'atoms-links--links',
30
+ 'atoms-lists--definition-list',
31
+ 'atoms-lists--unordered-list',
32
+ 'atoms-lists--ordered-list',
33
+ 'atoms-tables--table',
34
+ 'atoms-text--headings-examples',
35
+ 'atoms-text--blockquote-example',
36
+ 'atoms-text--preformatted',
37
+ 'atoms-text--random',
38
+ 'atoms-videos--wide',
39
+ 'atoms-videos--full',
40
+ 'molecules-cards--card-example',
41
+ 'molecules-cards--card-with-background',
42
+ 'molecules-cta--cta-example',
43
+ 'molecules-menus--breadcrumbs',
44
+ 'molecules-menus--inline',
45
+ 'molecules-menus--main',
46
+ 'molecules-menus--social',
47
+ 'molecules-menus-pager--pager-example',
48
+ 'molecules-status--status-examples',
49
+ 'molecules-tabs--js-tabs',
50
+ 'organisms-grids--default-grid',
51
+ 'organisms-grids--card-grid',
52
+ 'organisms-grids--cta-grid',
53
+ 'organisms-site--footer',
54
+ 'organisms-site--header',
55
+ 'templates-layouts--full-width',
56
+ 'templates-layouts--with-sidebar',
57
+ 'templates-place-holder--place-holder',
58
+ 'pages-content-types--article',
59
+ 'pages-landing-pages--home',
60
+ ],
61
+ };
@@ -0,0 +1,61 @@
1
+ module.exports = {
2
+ storybookBuildDir: '../../../../.out',
3
+ pa11y: {
4
+ includeNotices: false,
5
+ includeWarnings: false,
6
+ runners: ['axe'],
7
+ },
8
+ // A11y linting is done on a component-by-component
9
+ // basis, which results in the linter reporting some errors that
10
+ // should be ignored. These codes and descriptions allow for those
11
+ // errors to be targeted specifically.
12
+ ignore: {
13
+ codes: ['landmark-one-main', 'page-has-heading-one'],
14
+ descriptions: ['Ensures all page content is contained by landmarks'],
15
+ },
16
+ // List of storybook component IDs defined and used in this project.
17
+ components: [
18
+ 'base-colors--palettes',
19
+ 'base-motion--usage',
20
+ 'atoms-button--twig',
21
+ 'atoms-button--twig-alt',
22
+ 'atoms-forms--checkboxes',
23
+ 'atoms-forms--radio-buttons',
24
+ 'atoms-forms--select-dropdowns',
25
+ 'atoms-forms--textfields-examples',
26
+ 'atoms-images--images',
27
+ 'atoms-images--figures',
28
+ 'atoms-images--icons',
29
+ 'atoms-links--links',
30
+ 'atoms-lists--definition-list',
31
+ 'atoms-lists--unordered-list',
32
+ 'atoms-lists--ordered-list',
33
+ 'atoms-tables--table',
34
+ 'atoms-text--headings-examples',
35
+ 'atoms-text--blockquote-example',
36
+ 'atoms-text--preformatted',
37
+ 'atoms-text--random',
38
+ 'atoms-videos--wide',
39
+ 'atoms-videos--full',
40
+ 'molecules-cards--card-example',
41
+ 'molecules-cards--card-with-background',
42
+ 'molecules-cta--cta-example',
43
+ 'molecules-menus--breadcrumbs',
44
+ 'molecules-menus--inline',
45
+ 'molecules-menus--main',
46
+ 'molecules-menus--social',
47
+ 'molecules-menus-pager--pager-example',
48
+ 'molecules-status--status-examples',
49
+ 'molecules-tabs--js-tabs',
50
+ 'organisms-grids--default-grid',
51
+ 'organisms-grids--card-grid',
52
+ 'organisms-grids--cta-grid',
53
+ 'organisms-site--footer',
54
+ 'organisms-site--header',
55
+ 'templates-layouts--full-width',
56
+ 'templates-layouts--with-sidebar',
57
+ 'templates-place-holder--place-holder',
58
+ 'pages-content-types--article',
59
+ 'pages-landing-pages--home',
60
+ ],
61
+ };
@@ -0,0 +1 @@
1
+ import '../../../../../components/style.scss';
@@ -0,0 +1 @@
1
+ import '../../../../../../components/style.scss';
@@ -0,0 +1 @@
1
+ import '../../../../components/style.scss';
@@ -0,0 +1 @@
1
+ import '../../../../../components/style.scss';
@@ -0,0 +1 @@
1
+ import '../../../../../../components/style.scss';
@@ -0,0 +1,87 @@
1
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2
+ const globImporter = require('node-sass-glob-importer');
3
+ const fs = require('fs-extra');
4
+
5
+ let babelConfig;
6
+ let postcssConfig;
7
+
8
+ // Check if custom babel config is available.
9
+ if (fs.existsSync('./config/babel.config.js')) {
10
+ babelConfig = './config/babel.config.js';
11
+ } else {
12
+ babelConfig = './node_modules/emulsify-core/config/babel.config.js';
13
+ }
14
+
15
+ // Check if custom postcss config is available.
16
+ if (fs.existsSync('./config/postcss.config.js')) {
17
+ postcssConfig = './config/postcss.config.js';
18
+ } else {
19
+ postcssConfig = './node_modules/emulsify-core/config/postcss.config.js';
20
+ }
21
+
22
+ const JSLoader = {
23
+ test: /^(?!.*\.(stories|component)\.js$).*\.js$/,
24
+ exclude: /node_modules/,
25
+ loader: 'babel-loader',
26
+ options: {
27
+ configFile: babelConfig,
28
+ },
29
+ };
30
+
31
+ const ImageLoader = {
32
+ test: /\.(png|svg|jpg|gif)$/i,
33
+ exclude: /icons\/.*\.svg$/,
34
+ loader: 'file-loader',
35
+ };
36
+
37
+ const CSSLoader = {
38
+ test: /\.s[ac]ss$/i,
39
+ exclude: /node_modules/,
40
+ use: [
41
+ MiniCssExtractPlugin.loader,
42
+ {
43
+ loader: 'css-loader',
44
+ options: {
45
+ sourceMap: true,
46
+ url: false,
47
+ },
48
+ },
49
+ {
50
+ loader: 'postcss-loader',
51
+ options: {
52
+ sourceMap: true,
53
+ postcssOptions: {
54
+ config: postcssConfig,
55
+ plugins: [['autoprefixer']],
56
+ },
57
+ },
58
+ },
59
+ {
60
+ loader: 'sass-loader',
61
+ options: {
62
+ sourceMap: true,
63
+ sassOptions: {
64
+ importer: globImporter(),
65
+ outputStyle: 'compressed',
66
+ },
67
+ },
68
+ },
69
+ ],
70
+ };
71
+
72
+ const SVGSpriteLoader = {
73
+ test: /icons\/.*\.svg$/, // your icons directory
74
+ loader: 'svg-sprite-loader',
75
+ options: {
76
+ extract: true,
77
+ runtimeCompat: true,
78
+ spriteFilename: './icons.svg',
79
+ },
80
+ };
81
+
82
+ module.exports = {
83
+ JSLoader,
84
+ CSSLoader,
85
+ SVGSpriteLoader,
86
+ ImageLoader,
87
+ };
@@ -0,0 +1,87 @@
1
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2
+ const globImporter = require('node-sass-glob-importer');
3
+ const fs = require('fs-extra');
4
+
5
+ let babelConfig;
6
+ let postcssConfig;
7
+
8
+ // Check if custom babel config is available.
9
+ if (fs.existsSync('./config/babel.config.js')) {
10
+ babelConfig = './config/babel.config.js';
11
+ } else {
12
+ babelConfig = './node_modules/@emulsify/core/config/babel.config.js';
13
+ }
14
+
15
+ // Check if custom postcss config is available.
16
+ if (fs.existsSync('./config/postcss.config.js')) {
17
+ postcssConfig = './config/postcss.config.js';
18
+ } else {
19
+ postcssConfig = './node_modules/@emulsify/core/config/postcss.config.js';
20
+ }
21
+
22
+ const JSLoader = {
23
+ test: /^(?!.*\.(stories|component)\.js$).*\.js$/,
24
+ exclude: /node_modules/,
25
+ loader: 'babel-loader',
26
+ options: {
27
+ configFile: babelConfig,
28
+ },
29
+ };
30
+
31
+ const ImageLoader = {
32
+ test: /\.(png|svg|jpg|gif)$/i,
33
+ exclude: /icons\/.*\.svg$/,
34
+ loader: 'file-loader',
35
+ };
36
+
37
+ const CSSLoader = {
38
+ test: /\.s[ac]ss$/i,
39
+ exclude: /node_modules/,
40
+ use: [
41
+ MiniCssExtractPlugin.loader,
42
+ {
43
+ loader: 'css-loader',
44
+ options: {
45
+ sourceMap: true,
46
+ url: false,
47
+ },
48
+ },
49
+ {
50
+ loader: 'postcss-loader',
51
+ options: {
52
+ sourceMap: true,
53
+ postcssOptions: {
54
+ config: postcssConfig,
55
+ plugins: [['autoprefixer']],
56
+ },
57
+ },
58
+ },
59
+ {
60
+ loader: 'sass-loader',
61
+ options: {
62
+ sourceMap: true,
63
+ sassOptions: {
64
+ importer: globImporter(),
65
+ outputStyle: 'compressed',
66
+ },
67
+ },
68
+ },
69
+ ],
70
+ };
71
+
72
+ const SVGSpriteLoader = {
73
+ test: /icons\/.*\.svg$/, // your icons directory
74
+ loader: 'svg-sprite-loader',
75
+ options: {
76
+ extract: true,
77
+ runtimeCompat: true,
78
+ spriteFilename: './icons.svg',
79
+ },
80
+ };
81
+
82
+ module.exports = {
83
+ JSLoader,
84
+ CSSLoader,
85
+ SVGSpriteLoader,
86
+ ImageLoader,
87
+ };
@@ -0,0 +1,48 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ const path = require('path');
3
+ const webpack = require('webpack');
4
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
5
+ const _MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
+ const _ImageminPlugin = require('imagemin-webpack-plugin').default;
7
+ const _SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
8
+ const glob = require('glob');
9
+
10
+ const imagePath = path.resolve(__dirname, '../../../../assets/images');
11
+
12
+ const MiniCssExtractPlugin = new _MiniCssExtractPlugin({
13
+ filename: '[name].css',
14
+ chunkFilename: '[id].css',
15
+ });
16
+
17
+ const ImageminPlugin = new _ImageminPlugin({
18
+ disable: process.env.NODE_ENV !== 'production',
19
+ externalImages: {
20
+ context: imagePath,
21
+ sources: glob.sync(path.resolve(imagePath, '**/*.{png,jpg,gif,svg}')),
22
+ destination: imagePath,
23
+ },
24
+ });
25
+
26
+ const SpriteLoaderPlugin = new _SpriteLoaderPlugin({
27
+ plainSprite: true,
28
+ });
29
+
30
+ const ProgressPlugin = new webpack.ProgressPlugin();
31
+
32
+ module.exports = {
33
+ ProgressPlugin,
34
+ MiniCssExtractPlugin,
35
+ ImageminPlugin,
36
+ SpriteLoaderPlugin,
37
+ CleanWebpackPlugin: new CleanWebpackPlugin({
38
+ protectWebpackAssets: false, // Required for removal of extra, unwanted dist/css/*.js files.
39
+ cleanOnceBeforeBuildPatterns: ['!*.{png,jpg,gif,svg}'],
40
+ cleanAfterEveryBuildPatterns: [
41
+ 'remove/**',
42
+ '!js',
43
+ 'css/**/*.js', // Remove all unwanted, auto generated JS files from dist/css folder.
44
+ 'css/**/*.js.map',
45
+ '!*.{png,jpg,gif,svg}',
46
+ ],
47
+ }),
48
+ };
@@ -0,0 +1,48 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ const path = require('path');
3
+ const webpack = require('webpack');
4
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
5
+ const _MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
+ const _ImageminPlugin = require('imagemin-webpack-plugin').default;
7
+ const _SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
8
+ const glob = require('glob');
9
+
10
+ const imagePath = path.resolve(__dirname, '../../../../../assets/images');
11
+
12
+ const MiniCssExtractPlugin = new _MiniCssExtractPlugin({
13
+ filename: '[name].css',
14
+ chunkFilename: '[id].css',
15
+ });
16
+
17
+ const ImageminPlugin = new _ImageminPlugin({
18
+ disable: process.env.NODE_ENV !== 'production',
19
+ externalImages: {
20
+ context: imagePath,
21
+ sources: glob.sync(path.resolve(imagePath, '**/*.{png,jpg,gif,svg}')),
22
+ destination: imagePath,
23
+ },
24
+ });
25
+
26
+ const SpriteLoaderPlugin = new _SpriteLoaderPlugin({
27
+ plainSprite: true,
28
+ });
29
+
30
+ const ProgressPlugin = new webpack.ProgressPlugin();
31
+
32
+ module.exports = {
33
+ ProgressPlugin,
34
+ MiniCssExtractPlugin,
35
+ ImageminPlugin,
36
+ SpriteLoaderPlugin,
37
+ CleanWebpackPlugin: new CleanWebpackPlugin({
38
+ protectWebpackAssets: false, // Required for removal of extra, unwanted dist/css/*.js files.
39
+ cleanOnceBeforeBuildPatterns: ['!*.{png,jpg,gif,svg}'],
40
+ cleanAfterEveryBuildPatterns: [
41
+ 'remove/**',
42
+ '!js',
43
+ 'css/**/*.js', // Remove all unwanted, auto generated JS files from dist/css folder.
44
+ 'css/**/*.js.map',
45
+ '!*.{png,jpg,gif,svg}',
46
+ ],
47
+ }),
48
+ };
@@ -0,0 +1,5 @@
1
+ function requireAll(r) {
2
+ r.keys().forEach(r);
3
+ }
4
+
5
+ requireAll(require.context('../../../../assets/icons/', true, /\.svg$/));
@@ -0,0 +1,5 @@
1
+ function requireAll(r) {
2
+ r.keys().forEach(r);
3
+ }
4
+
5
+ requireAll(require.context('../../../../../assets/icons/', true, /\.svg$/));
@@ -0,0 +1,72 @@
1
+ const path = require('path');
2
+ const glob = require('glob');
3
+ const loaders = require('./loaders');
4
+ const plugins = require('./plugins');
5
+
6
+ const webpackDir = path.resolve(__dirname);
7
+ const rootDir = path.resolve(__dirname, '../../../..');
8
+ const distDir = path.resolve(__dirname, '../../../../dist');
9
+
10
+ // Glob pattern for scss files that ignore file names prefixed with underscore.
11
+ const scssPattern = path.resolve(rootDir, 'components/**/!(_*).scss');
12
+ // Glob pattern for JS files.
13
+ const jsPattern = path.resolve(
14
+ rootDir,
15
+ 'components/**/!(*.stories|*.component|*.min|*.test).js',
16
+ );
17
+
18
+ // Prepare list of scss and js file for "entry".
19
+ function getEntries(scssMatcher, jsMatcher) {
20
+ const entries = {};
21
+
22
+ // SCSS entries
23
+ glob.sync(scssMatcher).forEach((file) => {
24
+ const filePath = file.split('components/')[1];
25
+ const newfilePath = `css/${filePath.replace('.scss', '')}`;
26
+ entries[newfilePath] = file;
27
+ });
28
+
29
+ // JS entries
30
+ glob.sync(jsMatcher).forEach((file) => {
31
+ const filePath = file.split('components/')[1];
32
+ const newfilePath = `js/${filePath.replace('.js', '')}`;
33
+ entries[newfilePath] = file;
34
+ });
35
+
36
+ entries.svgSprite = path.resolve(webpackDir, 'svgSprite.js');
37
+
38
+ // CSS Files.
39
+ glob.sync(`${webpackDir}/css/*js`).forEach((file) => {
40
+ const baseFileName = path.basename(file);
41
+ const newfilePath = `css/${baseFileName.replace('.js', '')}`;
42
+ entries[newfilePath] = file;
43
+ });
44
+
45
+ return entries;
46
+ }
47
+
48
+ module.exports = {
49
+ stats: {
50
+ errorDetails: true,
51
+ },
52
+ entry: getEntries(scssPattern, jsPattern),
53
+ module: {
54
+ rules: [
55
+ loaders.CSSLoader,
56
+ loaders.SVGSpriteLoader,
57
+ loaders.ImageLoader,
58
+ loaders.JSLoader,
59
+ ],
60
+ },
61
+ plugins: [
62
+ plugins.MiniCssExtractPlugin,
63
+ plugins.ImageminPlugin,
64
+ plugins.SpriteLoaderPlugin,
65
+ plugins.ProgressPlugin,
66
+ plugins.CleanWebpackPlugin,
67
+ ],
68
+ output: {
69
+ path: distDir,
70
+ filename: '[name].js',
71
+ },
72
+ };