@madgex/design-system 1.0.1 → 1.2.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/.browserlistrc +3 -0
- package/.prettierignore +1 -1
- package/.vscode/launch.json +8 -0
- package/README.md +11 -100
- package/docs/tokens/colour.njk +5 -3
- package/docs/tokens/icons.njk +26 -0
- package/docs/tokens/spacing.njk +16 -1
- package/fractal-theme/views/layouts/skeleton.nunj +22 -0
- package/fractal.js +31 -22
- package/{tasks → gulp-tasks}/css.js +3 -1
- package/{tasks → gulp-tasks}/fractal.js +6 -4
- package/gulp-tasks/js-bundle.js +31 -0
- package/gulp-tasks/svgsprite.js +42 -0
- package/{tasks → gulp-tasks}/tokens.js +1 -1
- package/gulpfile.js +9 -5
- package/package.json +44 -15
- package/server.js +14 -0
- package/src/components/_preview.njk +13 -10
- package/src/components/icon/icon.config.js +43 -0
- package/src/components/icon/icon.njk +3 -0
- package/src/components/icon/icon.scss +6 -0
- package/src/components/similar-jobs-item/_macro.njk +3 -0
- package/src/components/similar-jobs-item/_template.njk +18 -0
- package/src/components/similar-jobs-item/similar-jobs-item.config.js +9 -0
- package/src/components/similar-jobs-item/similar-jobs-item.njk +8 -0
- package/src/components/similar-jobs-item/similar-jobs-item.scss +5 -0
- package/src/icons/bike.svg +4 -0
- package/src/icons/camera.svg +7 -0
- package/src/js/common.js +11 -0
- package/src/patterns/similar-jobs/_macro.njk +3 -0
- package/src/patterns/similar-jobs/_template.njk +19 -0
- package/src/patterns/similar-jobs/similar-jobs.config.js +30 -0
- package/src/patterns/similar-jobs/similar-jobs.njk +3 -0
- package/src/scss/functions/_color.scss +0 -0
- package/src/{core → scss}/index.scss +1 -1
- package/{tokens → src/tokens}/_config.js +11 -11
- package/{tokens → src/tokens}/color.json +1 -0
- package/webpack.config.js +117 -0
- package/src/patterns/form/form.njk +0 -2
- /package/src/{core/functions/_color.scss → patterns/similar-jobs/similar-jobs.scss} +0 -0
- /package/src/{core → scss}/functions/__index.scss +0 -0
- /package/src/{core → scss}/helpers/__index.scss +0 -0
- /package/src/{core → scss}/helpers/_media-queries.scss +0 -0
- /package/src/{core → scss}/utilities/__index.scss +0 -0
- /package/src/{core → scss}/utilities/_clearfix.scss +0 -0
- /package/src/{core → scss}/utilities/_mixins.scss +0 -0
- /package/src/{core → scss}/utilities/_visually-hidden.scss +0 -0
- /package/src/{core → scss}/vendor/_sass-mq.scss +0 -0
- /package/{tokens → src/tokens}/font.json +0 -0
- /package/{tokens → src/tokens}/size.json +0 -0
package/.browserlistrc
ADDED
package/.prettierignore
CHANGED
package/.vscode/launch.json
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
5
|
"version": "0.2.0",
|
|
6
6
|
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch via NPM",
|
|
11
|
+
"runtimeExecutable": "npm",
|
|
12
|
+
"runtimeArgs": ["run-script", "debug"],
|
|
13
|
+
"port": 9229
|
|
14
|
+
},
|
|
7
15
|
{
|
|
8
16
|
"name": "GulpTester",
|
|
9
17
|
"type": "node",
|
package/README.md
CHANGED
|
@@ -1,112 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Madgex Design System
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
```bash
|
|
5
|
-
style-dictionary build
|
|
6
|
-
```
|
|
7
|
-
|
|
8
|
-
You should see something like this output:
|
|
9
|
-
```
|
|
10
|
-
Reading config file from ./config.json
|
|
11
|
-
Building all platforms
|
|
12
|
-
|
|
13
|
-
scss
|
|
14
|
-
✔︎ build/scss/_variables.scss
|
|
3
|
+
A work-in progress Design System for building a UI for Madgex products.
|
|
15
4
|
|
|
16
|
-
|
|
17
|
-
✔︎ build/android/font_dimens.xml
|
|
5
|
+
## Usage
|
|
18
6
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
✔︎ build/ios/StyleDictionaryColor.m
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Pat yourself on the back, you just built your first style dictionary! Moving on, take a look at what we have built. This should have created a build directory and it should look like this:
|
|
25
|
-
```
|
|
26
|
-
├── android/
|
|
27
|
-
│ ├── font_dimens.xml
|
|
28
|
-
│ ├── colors.xml
|
|
29
|
-
├── scss/
|
|
30
|
-
│ ├── _variables.scss
|
|
31
|
-
├── ios/
|
|
32
|
-
│ ├── StyleDictionaryColor.h
|
|
33
|
-
│ ├── StyleDictionaryColor.m
|
|
7
|
+
```bash
|
|
8
|
+
npm install @madgex/design-system --save
|
|
34
9
|
```
|
|
35
10
|
|
|
36
|
-
|
|
11
|
+
## Importing styles
|
|
37
12
|
|
|
38
|
-
|
|
39
|
-
```xml
|
|
40
|
-
<!-- font_dimens.xml -->
|
|
41
|
-
<resources>
|
|
42
|
-
<dimen name="size_font_small">12.00sp</dimen>
|
|
43
|
-
<dimen name="size_font_medium">16.00sp</dimen>
|
|
44
|
-
<dimen name="size_font_large">32.00sp</dimen>
|
|
45
|
-
<dimen name="size_font_base">16.00sp</dimen>
|
|
46
|
-
</resources>
|
|
13
|
+
You'll need to import the Madgex DS styles into your main Sass file.
|
|
47
14
|
|
|
48
|
-
|
|
49
|
-
<resources>
|
|
50
|
-
<color name="color_base_gray_light">#CCCCCC</color>
|
|
51
|
-
<color name="color_base_gray_medium">#999999</color>
|
|
52
|
-
<color name="color_base_gray_dark">#111111</color>
|
|
53
|
-
<color name="color_font_base">#111111</color>
|
|
54
|
-
<color name="color_font_secondary">#999999</color>
|
|
55
|
-
<color name="color_font_tertiary">#CCCCCC</color>
|
|
56
|
-
</resources>
|
|
57
|
-
```
|
|
15
|
+
To import add the below to your Sass file:
|
|
58
16
|
|
|
59
|
-
**SCSS**
|
|
60
17
|
```scss
|
|
61
|
-
|
|
62
|
-
$color-base-gray-light: #CCCCCC;
|
|
63
|
-
$color-base-gray-medium: #999999;
|
|
64
|
-
$color-base-gray-dark: #111111;
|
|
65
|
-
$color-font-base: #111111;
|
|
66
|
-
$color-font-secondary: #999999;
|
|
67
|
-
$color-font-tertiary: #CCCCCC;
|
|
68
|
-
$size-font-small: 0.75rem;
|
|
69
|
-
$size-font-medium: 1rem;
|
|
70
|
-
$size-font-large: 2rem;
|
|
71
|
-
$size-font-base: 1rem;
|
|
18
|
+
@import 'node_modules/@madgex/design-system/public/css/index.css';
|
|
72
19
|
```
|
|
73
20
|
|
|
74
|
-
|
|
75
|
-
```objc
|
|
76
|
-
@implementation StyleDictionaryColor
|
|
77
|
-
|
|
78
|
-
+ (UIColor *)color:(StyleDictionaryColorName)colorEnum{
|
|
79
|
-
return [[self values] objectAtIndex:colorEnum];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
+ (NSArray *)values {
|
|
83
|
-
static NSArray* colorArray;
|
|
84
|
-
static dispatch_once_t onceToken;
|
|
85
|
-
|
|
86
|
-
dispatch_once(&onceToken, ^{
|
|
87
|
-
colorArray = @[
|
|
88
|
-
[UIColor colorWithRed:0.80f green:0.80f blue:0.80f alpha:1.0f],
|
|
89
|
-
[UIColor colorWithRed:0.60f green:0.60f blue:0.60f alpha:1.0f],
|
|
90
|
-
[UIColor colorWithRed:0.07f green:0.07f blue:0.07f alpha:1.0f],
|
|
91
|
-
[UIColor colorWithRed:0.07f green:0.07f blue:0.07f alpha:1.0f],
|
|
92
|
-
[UIColor colorWithRed:0.60f green:0.60f blue:0.60f alpha:1.0f],
|
|
93
|
-
[UIColor colorWithRed:0.80f green:0.80f blue:0.80f alpha:1.0f]
|
|
94
|
-
];
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return colorArray;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@end
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Pretty nifty! This shows a few things happening:
|
|
104
|
-
1. The build system does a deep merge of all the property JSON files defined in the `source` attribute of `config.json`. This allows you to split up the property JSON files however you want. There are 2 JSON files with `color` as the top level key, but they get merged properly.
|
|
105
|
-
1. The build system resolves references to other style properties. `{size.font.medium.value}` gets resolved properly
|
|
106
|
-
1. The build system handles references to property values in other files as well as you can see in `properties/color/font.json`
|
|
107
|
-
|
|
108
|
-
Now lets make a change and see how that affects things. Open up `properties/color/base.json` and change `"#111111"` to `"#000000"`. After you make that change, save the file and re-run the build command `style-dictionary build`. Open up the build files and take a look.
|
|
109
|
-
|
|
110
|
-
**Huzzah!**
|
|
21
|
+
## Releases
|
|
111
22
|
|
|
112
|
-
|
|
23
|
+
With every commit to `master` the build server attempts to create a new version using [semantic-release](https://semantic-release.gitbook.io/semantic-release/) and deploys to `NPM`.
|
package/docs/tokens/colour.njk
CHANGED
|
@@ -6,24 +6,26 @@ title: Colour Palette | Madgex Design System
|
|
|
6
6
|
|
|
7
7
|
Your context and coding style determine how you access MDS color tokens in code.
|
|
8
8
|
|
|
9
|
+
{#
|
|
9
10
|
| Context | Usage | Example |
|
|
10
11
|
|---|---|---|
|
|
11
12
|
| function | `color: color(color)` | `color: color('primary')` |
|
|
13
|
+
#}
|
|
12
14
|
|
|
13
15
|
{# <pre>{{ tokens.color | dump }}</pre> #}
|
|
14
16
|
|
|
15
17
|
{% macro swatch(item) %}
|
|
16
18
|
<div class="color">
|
|
17
19
|
<div class="swatch" style="background-color: {{ item.value }}"></div>
|
|
18
|
-
<span>{{ item.value }}</span>
|
|
20
|
+
<span><code>{{ item.value }}</code></span>
|
|
19
21
|
<span>{{ item.comment }}</span>
|
|
20
22
|
<span>
|
|
21
23
|
<em>SCSS:</em>
|
|
22
|
-
{{ item.path }}
|
|
24
|
+
<code>$mds-{{ item.path | join('-') | replace(",", "-") }}</code>
|
|
23
25
|
</span>
|
|
24
26
|
<span>
|
|
25
27
|
<em>JavaScript:</em>
|
|
26
|
-
{{item.name}}
|
|
28
|
+
<code>{{item.name}}</code>
|
|
27
29
|
</span>
|
|
28
30
|
{# <pre>{{ item | jsonify }}</pre> #}
|
|
29
31
|
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Icons | Madgex Design System
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
All icons available in MDS
|
|
6
|
+
|
|
7
|
+
{# <pre>{{ icons | dump }}</pre> #}
|
|
8
|
+
|
|
9
|
+
{% macro Icon(params) %}
|
|
10
|
+
<svg class="mds-icon mds-icon--{{ params.name }}{% if class %} {{ class }}{% endif %}">
|
|
11
|
+
<use xlink:href="{{ '/assets/icons.svg' | path }}#{{ params.name }}" />
|
|
12
|
+
</svg>
|
|
13
|
+
{% endmacro %}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<div class="colors" style="background-color: grey; color: black;">
|
|
17
|
+
{% for icon in icons %}
|
|
18
|
+
<p>
|
|
19
|
+
{{ Icon({
|
|
20
|
+
name: icon.name
|
|
21
|
+
}) }}
|
|
22
|
+
|
|
23
|
+
{{ icon.name }}
|
|
24
|
+
</p>
|
|
25
|
+
{% endfor %}
|
|
26
|
+
</div>
|
package/docs/tokens/spacing.njk
CHANGED
|
@@ -2,4 +2,19 @@
|
|
|
2
2
|
title: Spacing | Madgex Design System
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<style>
|
|
6
|
+
.space-example {
|
|
7
|
+
width: 100px;
|
|
8
|
+
display: block;
|
|
9
|
+
background-color: #005ea2;
|
|
10
|
+
}
|
|
11
|
+
</style>
|
|
12
|
+
|
|
13
|
+
Spacing used in MDS
|
|
14
|
+
|
|
15
|
+
| Token | Value | Example |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
{%- for key, item in tokens.size.space %}
|
|
18
|
+
| {% if item.path | length %}$mds-{{ item.path | join('-') }}{% endif %} | {{item.original.value}} | <span class="space-example" style="height: {{item.original.value}};"></span> |
|
|
19
|
+
{%- endfor -%}
|
|
20
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="{{ frctl.theme.get('lang') | default('en') }}" dir="{{ 'rtl' if frctl.theme.get('rtl') else 'ltr' }}" class="no-js">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<script>
|
|
7
|
+
window.frctl = {
|
|
8
|
+
env: '{% if frctl.env.server %}server{% else %}static{% endif %}'
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
<script>var cl = document.querySelector('html').classList; cl.remove('no-js'); cl.add('has-js');</script>
|
|
12
|
+
<meta name="robots" content="noindex">
|
|
13
|
+
|
|
14
|
+
{% include 'partials/head.nunj' %}
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
|
|
18
|
+
{% block page %}{% endblock %}
|
|
19
|
+
|
|
20
|
+
{% include 'partials/foot.nunj' %}
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
package/fractal.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const fractal = (module.exports = require('@frctl/fractal').create()); // eslint-disable-line
|
|
2
|
+
const path = require('path');
|
|
2
3
|
|
|
3
|
-
const fractal = Fractal.create();
|
|
4
|
-
// const fractal = (module.exports = require('@frctl/fractal').create());
|
|
5
4
|
const mandelbrot = require('@frctl/mandelbrot');
|
|
6
|
-
const path = require('path');
|
|
7
5
|
const nunjucks = require('@frctl/nunjucks')({
|
|
8
|
-
paths: [
|
|
6
|
+
paths: [
|
|
7
|
+
path.resolve(__dirname, 'src/components'),
|
|
8
|
+
path.resolve(__dirname, 'src/patterns'),
|
|
9
|
+
path.resolve(__dirname, 'src/'),
|
|
10
|
+
],
|
|
9
11
|
// pristine: true,
|
|
10
12
|
filters: {
|
|
11
13
|
// filter-name: function filterFunc(){}
|
|
@@ -19,22 +21,25 @@ const nunjucks = require('@frctl/nunjucks')({
|
|
|
19
21
|
// extension-name: function extensionFunc(){}
|
|
20
22
|
},
|
|
21
23
|
});
|
|
22
|
-
const pkg = require('./package.json');
|
|
23
|
-
const tokens = require('./tokens/build/js/_variables-module');
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const pkg = require(path.join(__dirname, 'package.json')); // eslint-disable-line
|
|
26
|
+
const tokens = require('./dist/_tokens/js/_tokens-module');
|
|
27
|
+
const icons = require('./dist/assets/icons.json');
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
*
|
|
29
|
+
/**
|
|
30
|
+
* Metadata
|
|
30
31
|
*/
|
|
31
32
|
fractal.set('project.title', 'Madgex Design System');
|
|
33
|
+
// Provide the package.json "version" to the templates
|
|
32
34
|
fractal.set('project.version', pkg.version);
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
fractal.components.engine(nunjucks); // use Nunjucks for components
|
|
37
|
+
fractal.components.set('ext', '.njk');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Files location
|
|
36
41
|
*/
|
|
37
|
-
fractal.components.set('path', path.join(__dirname, 'src
|
|
42
|
+
fractal.components.set('path', path.join(__dirname, 'src'));
|
|
38
43
|
fractal.components.set('default.collated', 'true');
|
|
39
44
|
fractal.components.set('default.preview', '@preview');
|
|
40
45
|
|
|
@@ -46,18 +51,21 @@ fractal.docs.set('ext', '.njk'); // default is '.md'
|
|
|
46
51
|
fractal.docs.set('path', path.join(__dirname, 'docs'));
|
|
47
52
|
fractal.docs.set('default.context', {
|
|
48
53
|
tokens,
|
|
54
|
+
icons,
|
|
49
55
|
});
|
|
50
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Build options
|
|
59
|
+
*/
|
|
60
|
+
// If you change the build destination, you should adapt webpack.common.js "output.path" too.
|
|
61
|
+
fractal.web.set('builder.dest', path.join(__dirname, '/public'));
|
|
62
|
+
|
|
51
63
|
/*
|
|
52
64
|
* Tell the Fractal web preview plugin where to look for static assets.
|
|
53
65
|
*/
|
|
54
66
|
fractal.web.set('static.path', path.join(__dirname, '/dist'));
|
|
55
67
|
|
|
56
68
|
const madgexTheme = mandelbrot({
|
|
57
|
-
// skin: 'black',
|
|
58
|
-
// any other theme configuration values here
|
|
59
|
-
// nav: ['docs', 'components'],
|
|
60
|
-
// which panels to show
|
|
61
69
|
panels: ['html', 'notes', 'view', 'context', 'resources', 'info'],
|
|
62
70
|
styles: ['default', '/assets/css/styles.css'],
|
|
63
71
|
// scripts: ['default', '/assets/theme/js/scripts.js'],
|
|
@@ -74,7 +82,8 @@ madgexTheme.addStatic(`${__dirname}/fractal-theme/assets`, '/assets');
|
|
|
74
82
|
|
|
75
83
|
fractal.web.theme(madgexTheme);
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Server configuration
|
|
87
|
+
*/
|
|
88
|
+
fractal.web.set('server.port', 4000);
|
|
89
|
+
fractal.web.set('server.sync', true);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const gulp = require('gulp');
|
|
2
2
|
const sass = require('gulp-sass');
|
|
3
|
+
const rename = require('gulp-rename');
|
|
3
4
|
|
|
4
5
|
function css() {
|
|
5
6
|
return gulp
|
|
6
|
-
.src(
|
|
7
|
+
.src('src/scss/index.scss')
|
|
7
8
|
.pipe(
|
|
8
9
|
sass.sync({
|
|
9
10
|
outputStyle: 'expanded',
|
|
@@ -12,6 +13,7 @@ function css() {
|
|
|
12
13
|
})
|
|
13
14
|
)
|
|
14
15
|
.on('error', sass.logError)
|
|
16
|
+
.pipe(rename('index.css'))
|
|
15
17
|
.pipe(gulp.dest('dist/css'));
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const fractal = require('../fractal.js');
|
|
2
|
-
// import the Fractal instance configured in the fractal.js file
|
|
3
|
-
const logger = fractal.cli.console; // make use of Fractal's console object for logging
|
|
4
|
-
|
|
5
1
|
/*
|
|
6
2
|
* An example of a Gulp task that starts a Fractal development server.
|
|
7
3
|
*/
|
|
8
4
|
|
|
9
5
|
function fractalStart() {
|
|
6
|
+
const fractal = require('../fractal.js');
|
|
7
|
+
// import the Fractal instance configured in the fractal.js file
|
|
8
|
+
const logger = fractal.cli.console; // make use of Fractal's console object for logging
|
|
10
9
|
const server = fractal.web.server({
|
|
11
10
|
sync: true,
|
|
12
11
|
});
|
|
@@ -17,6 +16,9 @@ function fractalStart() {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
function fractalBuild() {
|
|
19
|
+
const fractal = require('../fractal.js');
|
|
20
|
+
// import the Fractal instance configured in the fractal.js file
|
|
21
|
+
const logger = fractal.cli.console; // make use of Fractal's console object for logging
|
|
20
22
|
const builder = fractal.web.builder();
|
|
21
23
|
builder.on('progress', (completed, total) => logger.update(`Exported ${completed} of ${total} items`, 'info'));
|
|
22
24
|
builder.on('error', (err) => logger.error(err.message));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const gulp = require('gulp');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
const gulpWebpack = require('webpack-stream');
|
|
4
|
+
|
|
5
|
+
function jsbundle() {
|
|
6
|
+
return gulp
|
|
7
|
+
.src('src/js/common.js')
|
|
8
|
+
.pipe(
|
|
9
|
+
gulpWebpack(
|
|
10
|
+
{
|
|
11
|
+
output: {
|
|
12
|
+
filename: 'common.js',
|
|
13
|
+
},
|
|
14
|
+
// watch: true,
|
|
15
|
+
module: {
|
|
16
|
+
rules: [
|
|
17
|
+
{
|
|
18
|
+
test: /\.js$/,
|
|
19
|
+
exclude: /node_modules/,
|
|
20
|
+
loader: 'babel-loader',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
webpack
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
.pipe(gulp.dest('dist/js/'));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.jsbundle = jsbundle;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const gulp = require('gulp');
|
|
2
|
+
const svgstore = require('gulp-svgstore');
|
|
3
|
+
const svgmin = require('gulp-svgmin');
|
|
4
|
+
const tap = require('gulp-tap');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
function svgsprite() {
|
|
9
|
+
const icons = [];
|
|
10
|
+
const stream = gulp
|
|
11
|
+
.src('./src/icons/*.svg')
|
|
12
|
+
.pipe(
|
|
13
|
+
svgmin((file) => {
|
|
14
|
+
const prefix = path.basename(file.relative, path.extname(file.relative));
|
|
15
|
+
return {
|
|
16
|
+
plugins: [
|
|
17
|
+
{
|
|
18
|
+
cleanupIDs: {
|
|
19
|
+
prefix: `${prefix}-`,
|
|
20
|
+
minify: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
})
|
|
26
|
+
)
|
|
27
|
+
.pipe(
|
|
28
|
+
tap((file) => {
|
|
29
|
+
icons.push({ name: file.stem });
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
.pipe(svgstore({ inlineSvg: true }))
|
|
33
|
+
.pipe(gulp.dest('dist/assets'));
|
|
34
|
+
|
|
35
|
+
stream.on('end', () => {
|
|
36
|
+
fs.writeFileSync('./dist/assets/icons.json', JSON.stringify(icons));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return stream;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.svgsprite = svgsprite;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const StyleDictionary = require('style-dictionary').extend(path.resolve('./tokens/_config.js'));
|
|
2
|
+
const StyleDictionary = require('style-dictionary').extend(path.resolve('./src/tokens/_config.js'));
|
|
3
3
|
|
|
4
4
|
function tokens(cb) {
|
|
5
5
|
StyleDictionary.buildAllPlatforms();
|
package/gulpfile.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const gulp = require('gulp');
|
|
2
2
|
const del = require('del');
|
|
3
|
-
const { tokens } = require('./tasks/tokens');
|
|
4
|
-
const { css } = require('./tasks/css');
|
|
5
|
-
const {
|
|
3
|
+
const { tokens } = require('./gulp-tasks/tokens');
|
|
4
|
+
const { css } = require('./gulp-tasks/css');
|
|
5
|
+
const { svgsprite } = require('./gulp-tasks/svgsprite');
|
|
6
|
+
const { jsbundle } = require('./gulp-tasks/js-bundle');
|
|
7
|
+
const { fractalStart, fractalBuild } = require('./gulp-tasks/fractal');
|
|
6
8
|
|
|
7
9
|
// ---
|
|
8
10
|
|
|
@@ -13,16 +15,18 @@ async function clean(cb) {
|
|
|
13
15
|
|
|
14
16
|
function watchFiles() {
|
|
15
17
|
gulp.watch(['src/core/**/*.scss', 'src/components/**/*.scss'], { awaitWriteFinish: true }, gulp.series(css));
|
|
16
|
-
gulp.watch('tokens/**/*.json', gulp.series(tokens));
|
|
18
|
+
gulp.watch('src/tokens/**/*.json', gulp.series(tokens));
|
|
17
19
|
// gulp.watch('./assets/js/**/*', gulp.series(scriptsLint, scripts));
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
const watch = gulp.parallel(watchFiles);
|
|
21
|
-
const build = gulp.series(clean, tokens, css, fractalBuild);
|
|
23
|
+
const build = gulp.series(clean, tokens, svgsprite, css, jsbundle, fractalBuild);
|
|
22
24
|
const dev = gulp.series(build, fractalStart, watch);
|
|
23
25
|
|
|
24
26
|
exports.clean = clean;
|
|
25
27
|
exports.css = css;
|
|
28
|
+
exports.jsbundle = jsbundle;
|
|
29
|
+
exports.svgsprite = svgsprite;
|
|
26
30
|
exports.build = build;
|
|
27
31
|
exports.dev = dev;
|
|
28
32
|
exports.tokens = tokens;
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madgex/design-system",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"scripts": {
|
|
5
|
+
"clean": "rimraf dist public tokens/build",
|
|
5
6
|
"commit": "commit",
|
|
6
7
|
"semantic-release": "semantic-release --prepare && npm run build && semantic-release --publish",
|
|
7
|
-
"tokens": "style-dictionary --config ./tokens/_config.js build",
|
|
8
|
-
"
|
|
9
|
-
"build": "
|
|
8
|
+
"tokens": "style-dictionary --config ./src/tokens/_config.js build",
|
|
9
|
+
"start": "gulp dev",
|
|
10
|
+
"build": "gulp build",
|
|
11
|
+
"build:icons": "svgo -f src/icons ./dist/assets/icons",
|
|
12
|
+
"build:webpack": "NODE_ENV=production webpack",
|
|
13
|
+
"build:fractal": "NODE_ENV=production fractal build",
|
|
10
14
|
"lint": "eslint .",
|
|
11
15
|
"lint-fix": "eslint . --fix"
|
|
12
16
|
},
|
|
@@ -18,24 +22,49 @@
|
|
|
18
22
|
"devDependencies": {
|
|
19
23
|
"@babel/core": "^7.4.4",
|
|
20
24
|
"@babel/preset-env": "^7.4.4",
|
|
21
|
-
"@commitlint/cli": "^7.
|
|
22
|
-
"@commitlint/config-conventional": "^7.
|
|
23
|
-
"@commitlint/prompt-cli": "^7.
|
|
25
|
+
"@commitlint/cli": "^7.6.1",
|
|
26
|
+
"@commitlint/config-conventional": "^7.6.0",
|
|
27
|
+
"@commitlint/prompt-cli": "^7.6.1",
|
|
24
28
|
"@frctl/fractal": "^1.1.7",
|
|
25
29
|
"@frctl/mandelbrot": "^1.2.1",
|
|
26
|
-
"@frctl/nunjucks": "^2.0.
|
|
30
|
+
"@frctl/nunjucks": "^2.0.1",
|
|
27
31
|
"@madgex/eslint-config-madgex": "^1.2.0",
|
|
28
|
-
"
|
|
32
|
+
"autoprefixer": "^9.5.1",
|
|
33
|
+
"babel-loader": "^8.0.6",
|
|
34
|
+
"commitizen": "^3.1.1",
|
|
35
|
+
"concurrently": "^4.1.0",
|
|
36
|
+
"css-loader": "^2.1.1",
|
|
37
|
+
"cssnano": "^4.1.10",
|
|
29
38
|
"cz-conventional-changelog": "^2.1.0",
|
|
30
|
-
"del": "^4.1.
|
|
39
|
+
"del": "^4.1.1",
|
|
40
|
+
"file-loader": "^3.0.1",
|
|
31
41
|
"flat": "^4.1.0",
|
|
32
|
-
"
|
|
42
|
+
"glob": "^7.1.4",
|
|
43
|
+
"gulp": "^4.0.2",
|
|
44
|
+
"gulp-rename": "^1.4.0",
|
|
33
45
|
"gulp-sass": "^4.0.2",
|
|
46
|
+
"gulp-svgmin": "^2.2.0",
|
|
47
|
+
"gulp-svgstore": "^7.0.1",
|
|
34
48
|
"gulp-tap": "^1.0.1",
|
|
35
|
-
"husky": "^
|
|
36
|
-
"lint-staged": "^8.1.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
49
|
+
"husky": "^2.3.0",
|
|
50
|
+
"lint-staged": "^8.1.7",
|
|
51
|
+
"mini-css-extract-plugin": "^0.6.0",
|
|
52
|
+
"node-sass": "^4.12.0",
|
|
53
|
+
"postcss": "^7.0.16",
|
|
54
|
+
"postcss-cli": "^6.1.2",
|
|
55
|
+
"postcss-loader": "^3.0.0",
|
|
56
|
+
"rimraf": "^2.6.3",
|
|
57
|
+
"sass-loader": "^7.1.0",
|
|
58
|
+
"semantic-release": "^15.13.12",
|
|
59
|
+
"style-dictionary": "^2.7.0",
|
|
60
|
+
"style-loader": "^0.23.1",
|
|
61
|
+
"svg-sprite-loader": "^4.1.6",
|
|
62
|
+
"svgo": "^1.2.2",
|
|
63
|
+
"svgo-loader": "^2.2.0",
|
|
64
|
+
"webpack": "^4.31.0",
|
|
65
|
+
"webpack-cli": "^3.3.2",
|
|
66
|
+
"webpack-dev-server": "^3.4.0",
|
|
67
|
+
"webpack-stream": "^5.2.1"
|
|
39
68
|
},
|
|
40
69
|
"config": {
|
|
41
70
|
"commitizen": {
|
package/server.js
ADDED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<link rel="stylesheet" href="{{ '/css/index.css' | path }}">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<link rel="stylesheet" href="{{ '/css/index.css' | path }}" />
|
|
8
7
|
|
|
9
|
-
</
|
|
10
|
-
<body style="padding: 30px;">
|
|
8
|
+
<title>{{ _target.title }} - {{ _config.project.title }}</title>
|
|
11
9
|
|
|
12
|
-
{
|
|
10
|
+
{% if _config.env !== 'development' %}
|
|
11
|
+
<link rel="stylesheet" href="{{ '/css/common.css' | path }}" />
|
|
12
|
+
{% endif %}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
<script type="text/javascript" src="{{ '/js/common.js' | path }}"></script>
|
|
15
|
+
</head>
|
|
16
|
+
<body style="padding: 30px;">
|
|
17
|
+
{{ yield | safe }}
|
|
18
|
+
</body>
|
|
15
19
|
</html>
|
|
16
|
-
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// module.exports = {
|
|
2
|
+
// title: 'Icons',
|
|
3
|
+
// context: {
|
|
4
|
+
// id: 'bike',
|
|
5
|
+
// },
|
|
6
|
+
// variants: [
|
|
7
|
+
// {
|
|
8
|
+
// name: 'camera',
|
|
9
|
+
// context: {
|
|
10
|
+
// id: 'camera',
|
|
11
|
+
// },
|
|
12
|
+
// },
|
|
13
|
+
// ],
|
|
14
|
+
// };
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Icon Pattern Config
|
|
18
|
+
* Loads icons from `assets` and creates the variants
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const glob = require('glob');
|
|
23
|
+
|
|
24
|
+
const iconsGlob = './src/icons/**/*.svg'; // TODO: Load from global config
|
|
25
|
+
const variants = [];
|
|
26
|
+
|
|
27
|
+
// Collect Icon Names
|
|
28
|
+
const files = glob.sync(iconsGlob) || [];
|
|
29
|
+
files.forEach((file) => {
|
|
30
|
+
const name = path.basename(file, '.svg');
|
|
31
|
+
variants.push({
|
|
32
|
+
name,
|
|
33
|
+
context: {
|
|
34
|
+
icon: name,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
title: 'Icon',
|
|
41
|
+
status: 'ready',
|
|
42
|
+
variants,
|
|
43
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div class="mds-similar-job{% if params.classes %} {{ params.classes }}{% endif %}">
|
|
2
|
+
<h3 class="mds-similar-job__header">
|
|
3
|
+
{%- if params.href %}
|
|
4
|
+
<a href="{{ params.href }}" class="mds-similar-job__link">
|
|
5
|
+
{{- params.title | safe -}}
|
|
6
|
+
</a>
|
|
7
|
+
{% else -%}
|
|
8
|
+
{{ params.title | safe }}
|
|
9
|
+
{%- endif -%}
|
|
10
|
+
</h3>
|
|
11
|
+
{%- if params.meta -%}
|
|
12
|
+
<ul class="mds-similar-job__meta">
|
|
13
|
+
{%- for item in params.meta -%}
|
|
14
|
+
<li class="mds-similar-job-meta__item">{{ item | safe }}</li>
|
|
15
|
+
{%- endfor -%}
|
|
16
|
+
</ul>
|
|
17
|
+
{%- endif -%}
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="m72.918 41.668c-2.082 0-3.957 0.41797-5.625 1.043l-4.793-7.918 1.457-3.543h0.625c1.25 0 2.082-0.83203 2.082-2.082s-0.83203-2.082-2.082-2.082h-6.25c-1.25 0-2.082 0.83203-2.082 2.082s0.83203 2.082 2.082 2.082h1.043l-0.83203 2.082h-18.961v-8.332h-10.418v4.168h6.25v5.832l-3.75 7.5c-1.457-0.625-2.9141-0.83203-4.582-0.83203-8.125 0-14.582 6.457-14.582 14.582s6.457 14.582 14.582 14.582 14.582-6.457 14.582-14.582c0-5-2.5-9.375-6.25-11.875l2.5-4.793 13.125 18.957h7.5c1.043 7.082 7.082 12.5 14.375 12.5 8.125 0 14.582-6.457 14.582-14.582 0.003906-8.332-6.4531-14.789-14.578-14.789zm-35.418 14.582c0 5.832-4.582 10.418-10.418 10.418-5.832 0-10.418-4.582-10.418-10.418 0-5.832 4.582-10.418 10.418-10.418 0.83203 0 1.875 0.20703 2.707 0.41797l-4.582 9.168c-0.20703 0.20703-0.20703 0.41406-0.20703 0.83203 0 1.25 0.83203 2.082 2.082 2.082 0.83203 0 1.457-0.41797 1.875-1.25l4.582-9.168c2.293 2.0859 3.9609 5.0039 3.9609 8.3359zm26.25-11.25c-2.707 2.293-4.582 5.418-5.207 9.168h-3.332l5.418-14.375zm2.082 3.543l3.332 5.625h-6.457c0.41797-2.293 1.668-4.168 3.125-5.625zm-14.375 3.332l-10-14.375h15.625zm21.461 14.793c-5 0-9.168-3.543-10.207-8.332l10.207-0.003907c1.25 0 2.082-0.83203 2.082-2.082 0-0.41797-0.20703-0.83203-0.41797-1.043l-5.207-8.75c1.043-0.41797 2.293-0.625 3.543-0.625 5.832 0 10.418 4.582 10.418 10.418-0.003907 5.832-4.5859 10.418-10.418 10.418z"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<g>
|
|
4
|
+
<path d="m56.25 56.25c0 3.4531-2.7969 6.25-6.25 6.25s-6.25-2.7969-6.25-6.25 2.7969-6.25 6.25-6.25 6.25 2.7969 6.25 6.25"/>
|
|
5
|
+
<path d="m81.25 33.332h-16.668l-4.168-8.332h-20.832l-4.168 8.332h-16.664c-3.543 0-6.25 2.707-6.25 6.25v33.332c0 3.332 2.707 6.25 6.25 6.25h62.5c3.543 0 6.25-2.918 6.25-6.25v-33.332c0-3.5391-2.707-6.25-6.25-6.25zm-31.25 37.5c-8.125 0-14.582-6.457-14.582-14.582s6.457-14.582 14.582-14.582 14.582 6.457 14.582 14.582-6.457 14.582-14.582 14.582z"/>
|
|
6
|
+
</g>
|
|
7
|
+
</svg>
|
package/src/js/common.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is the webpack entry point
|
|
2
|
+
|
|
3
|
+
// Here you can import your components, icons, etc.
|
|
4
|
+
// For example:
|
|
5
|
+
//
|
|
6
|
+
// import modal from 'components/Modal';
|
|
7
|
+
// import 'icons/home.svg';
|
|
8
|
+
//
|
|
9
|
+
// Webpack will automatically look for files relative to `assets/scripts/` and `assets/`.
|
|
10
|
+
|
|
11
|
+
console.log('MDS bundle loaded.');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{% from "../../components/similar-jobs-item/_macro.njk" import SimilarJobsItem %}
|
|
2
|
+
{%- if params.items -%}
|
|
3
|
+
<div class="mds-similar-jobs">
|
|
4
|
+
{%- if params.title -%}
|
|
5
|
+
<h2 class="mds-similar-jobs__header">{{params.title}}</h2>
|
|
6
|
+
{%- endif -%}
|
|
7
|
+
{%- if params.items -%}
|
|
8
|
+
<ul class="mds-similar-jobs__content">
|
|
9
|
+
{%- for item in params.items -%}
|
|
10
|
+
{%- if item.title -%}
|
|
11
|
+
<li class="mds-similar-jobs-content__item">
|
|
12
|
+
{{ SimilarJobsItem({title: item.title, href: item.href, classes: item.classes, meta: item.meta}) }}
|
|
13
|
+
</li>
|
|
14
|
+
{%- endif -%}
|
|
15
|
+
{%- endfor -%}
|
|
16
|
+
</ul>
|
|
17
|
+
{%- endif -%}
|
|
18
|
+
</div>
|
|
19
|
+
{%- endif -%}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
title: 'SimilarJobs',
|
|
3
|
+
context: {
|
|
4
|
+
title: 'Similar Jobs',
|
|
5
|
+
items: [
|
|
6
|
+
{
|
|
7
|
+
title: 'Marketing Manager',
|
|
8
|
+
href: '/job/marketing-manager',
|
|
9
|
+
classes: 'mds-similar-job--premium-job',
|
|
10
|
+
meta: ['London City', 'Market Rate', 'Apple Inc'],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
title: 'Head of Marketing',
|
|
14
|
+
href: '/job/head-of-marketing',
|
|
15
|
+
classes: 'mds-similar-job--promoted-job',
|
|
16
|
+
meta: ['London (Hackney)', 'Marketers Ltd'],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: 'Marketing Advisor',
|
|
20
|
+
href: '/job/marketing-advisor',
|
|
21
|
+
classes: 'mds-similar-job--premium-job',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
title: 'Marketing Researcher',
|
|
25
|
+
classes: '',
|
|
26
|
+
meta: ['London (Central)', '100K+'],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const config = {
|
|
2
|
-
source: ['tokens/**/*.json'],
|
|
2
|
+
source: ['src/tokens/**/*.json'],
|
|
3
3
|
platforms: {
|
|
4
4
|
'css-variables': {
|
|
5
5
|
transformGroup: 'css',
|
|
6
|
-
buildPath: '
|
|
6
|
+
buildPath: 'dist/_tokens/css/',
|
|
7
7
|
prefix: 'mds',
|
|
8
8
|
files: [
|
|
9
9
|
{
|
|
10
|
-
destination: '
|
|
10
|
+
destination: '_tokens.css',
|
|
11
11
|
format: 'css/variables',
|
|
12
12
|
},
|
|
13
13
|
],
|
|
@@ -15,11 +15,11 @@ const config = {
|
|
|
15
15
|
'scss-variables': {
|
|
16
16
|
transformGroup: 'web',
|
|
17
17
|
// transforms: ['size/px'],
|
|
18
|
-
buildPath: '
|
|
18
|
+
buildPath: 'dist/_tokens/scss/',
|
|
19
19
|
prefix: 'mds',
|
|
20
20
|
files: [
|
|
21
21
|
{
|
|
22
|
-
destination: '
|
|
22
|
+
destination: '_tokens.scss',
|
|
23
23
|
// format: 'scss/variables',
|
|
24
24
|
format: 'scss/map-deep',
|
|
25
25
|
},
|
|
@@ -27,18 +27,18 @@ const config = {
|
|
|
27
27
|
},
|
|
28
28
|
sketch: {
|
|
29
29
|
transformGroup: 'web',
|
|
30
|
-
buildPath: '
|
|
30
|
+
buildPath: 'dist/_tokens/sketch/',
|
|
31
31
|
prefix: 'mds',
|
|
32
32
|
files: [
|
|
33
33
|
{
|
|
34
|
-
destination: '
|
|
34
|
+
destination: '_tokens.sketchpalette',
|
|
35
35
|
format: 'sketch/palette',
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
},
|
|
39
39
|
// json: {
|
|
40
40
|
// transformGroup: 'js',
|
|
41
|
-
// buildPath: '
|
|
41
|
+
// buildPath: 'dist/json/',
|
|
42
42
|
// files: [
|
|
43
43
|
// {
|
|
44
44
|
// destination: '_variables.json',
|
|
@@ -48,7 +48,7 @@ const config = {
|
|
|
48
48
|
// },
|
|
49
49
|
// 'js-es6': {
|
|
50
50
|
// transformGroup: 'js',
|
|
51
|
-
// buildPath: '
|
|
51
|
+
// buildPath: 'dist/js/',
|
|
52
52
|
// prefix: 'mds',
|
|
53
53
|
// files: [
|
|
54
54
|
// {
|
|
@@ -64,11 +64,11 @@ const config = {
|
|
|
64
64
|
// },
|
|
65
65
|
'js-module': {
|
|
66
66
|
transformGroup: 'js',
|
|
67
|
-
buildPath: '
|
|
67
|
+
buildPath: 'dist/_tokens/js/',
|
|
68
68
|
prefix: 'mds',
|
|
69
69
|
files: [
|
|
70
70
|
{
|
|
71
|
-
destination: '
|
|
71
|
+
destination: '_tokens-module.js',
|
|
72
72
|
format: 'javascript/module',
|
|
73
73
|
},
|
|
74
74
|
],
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
const glob = require('glob');
|
|
4
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
5
|
+
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
|
|
6
|
+
|
|
7
|
+
const entry = {
|
|
8
|
+
common: path.resolve(__dirname, 'src/scripts/common.js'),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Skip icons if there’s none or Webpack will throw an error
|
|
12
|
+
const icons = glob.sync('./src/icons/**/*.svg');
|
|
13
|
+
if (icons.length) {
|
|
14
|
+
entry.icons = icons;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
|
19
|
+
resolve: {
|
|
20
|
+
modules: [path.resolve(__dirname, 'src/scripts'), path.resolve(__dirname, 'src'), 'node_modules'],
|
|
21
|
+
extensions: ['.js'],
|
|
22
|
+
},
|
|
23
|
+
entry,
|
|
24
|
+
output: {
|
|
25
|
+
path: path.resolve(__dirname, 'dist'),
|
|
26
|
+
publicPath: '/',
|
|
27
|
+
filename: '[name].js',
|
|
28
|
+
},
|
|
29
|
+
module: {
|
|
30
|
+
rules: [
|
|
31
|
+
{
|
|
32
|
+
test: /\.js$/,
|
|
33
|
+
exclude: /node_modules/,
|
|
34
|
+
loader: 'babel-loader',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
test: /\.scss$/,
|
|
38
|
+
use: [
|
|
39
|
+
{
|
|
40
|
+
loader: process.env.NODE_ENV === 'production' ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
41
|
+
},
|
|
42
|
+
'css-loader',
|
|
43
|
+
{
|
|
44
|
+
loader: 'postcss-loader',
|
|
45
|
+
options: {
|
|
46
|
+
plugins: [require('autoprefixer')(), require('cssnano')()],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
loader: 'sass-loader',
|
|
51
|
+
options: {
|
|
52
|
+
includePaths: ['node_modules'],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
test: /\.(svg|png|jpe?g|gif|woff|woff2|eot|ttf|otf)$/,
|
|
59
|
+
exclude: path.resolve('./src/icons'),
|
|
60
|
+
use: [
|
|
61
|
+
{
|
|
62
|
+
loader: 'file-loader',
|
|
63
|
+
options: {
|
|
64
|
+
name: '[name].[ext]',
|
|
65
|
+
outputPath: 'assets/',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
test: /\.svg$/,
|
|
72
|
+
include: path.resolve('./src/icons'),
|
|
73
|
+
use: [
|
|
74
|
+
{
|
|
75
|
+
loader: 'svg-sprite-loader',
|
|
76
|
+
options: {
|
|
77
|
+
extract: true,
|
|
78
|
+
spriteFilename: 'assets/icons/icon-sprite.svg',
|
|
79
|
+
// esModule: false,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
'svgo-loader',
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
plugins: [
|
|
88
|
+
new MiniCssExtractPlugin({
|
|
89
|
+
filename: '[name].css',
|
|
90
|
+
}),
|
|
91
|
+
new SpriteLoaderPlugin(),
|
|
92
|
+
],
|
|
93
|
+
devServer: {
|
|
94
|
+
historyApiFallback: true,
|
|
95
|
+
compress: true,
|
|
96
|
+
proxy: {
|
|
97
|
+
'**': 'http://localhost:4000',
|
|
98
|
+
},
|
|
99
|
+
port: 3000,
|
|
100
|
+
stats: {
|
|
101
|
+
colors: true,
|
|
102
|
+
},
|
|
103
|
+
overlay: true,
|
|
104
|
+
},
|
|
105
|
+
optimization: {
|
|
106
|
+
splitChunks: {
|
|
107
|
+
cacheGroups: {
|
|
108
|
+
styles: {
|
|
109
|
+
name: 'styles',
|
|
110
|
+
test: /\.css$/,
|
|
111
|
+
chunks: 'all',
|
|
112
|
+
enforce: true,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|