forked from KittyGiraudel/sass-guidelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-scripts.js
81 lines (70 loc) · 3.13 KB
/
package-scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module.exports = {
scripts: {
// Default command executed when running `npm start`
default: 'npm start build && npm start watch',
// Generates the icon sprite (after SVG optimisation through SVGO)
icons: [
'svgo assets/images/icons &&',
'spritesh',
'--input assets/images/icons',
'--output _includes/sprite.svg',
'--viewbox \'0 0 1024 1024\'',
'--prefix icon-'
].join(' '),
// Start the Jekyll server for development
watch: 'bundle exec jekyll s --incremental --config _config.yml,_config.dev.yml',
// Make sure the code is clean and working
test: 'npm start js.lint',
// Build the project
build: 'npm start js && jekyll build && _bin/testbuild',
js: {
default: 'npm start js.build',
build: 'npm start js.vendors && npm start js.utilities',
// Copy third-party vendor scripts into the `assets/js/vendor` folder to
// avoid maintaining our own (possibly outdated) version of these vendor
// Note: the `picturefill.min.js` script is not copied in the vendor
// folder because it is being included in the `<head>` instead of
// being bundled in the main JavaScript file like other vendors
// Note: this task is automatically run after `npm install`
vendors: [
'mkdir -p assets/js/vendor',
'cp node_modules/a11y-dialog/a11y-dialog.js assets/js/vendor',
'cp node_modules/blingdotjs/bling.js assets/js/vendor',
'cp node_modules/picturefill/dist/picturefill.min.js assets/js'
].join(' && '),
// Generates `_includes/utilities.js` from non-copied third-party vendor
// scripts which will be inlined in the `<head>` of the document for quick
// use instead of being bundled in the main JavaScript file (cf. through
// the `vendors` task)
utilities: [
'cat', [
'node_modules/fg-loadcss/src/loadCSS.js',
'node_modules/fg-loadcss/src/cssrelpreload.js',
'node_modules/woff2-feature-test/woff2.js',
'node_modules/OptimizedWebfontLoading/loadFont.js'
].join(' '),
'| uglifyjs > _includes/utilities.js'
].join(' '),
// Run the `standard` linter on all JavaScript files from the JS folder
// Note: the `assets/js/vendor` folder is naturally omitted by standard
lint: 'standard assets/js/**/*'
},
css: {
default: 'npm start css.critical && npm start css.clean',
// Optimise the critical CSS stylesheet to make it as tiny as possible for
// it to be inlined in the `<head>` of the document
clean: 'cleancss _includes/critical.css --output _includes/critical.css',
// Extract all critical styles from the main stylesheet to render “above-
// the-fold” content as quickly as possible
// Note: this needs the local server to be running (`npm start`) to work
// as it needs a URL to test against
critical: [
'criticalcss run',
'--url http://localhost:4000',
'--file _site/assets/css/main.css',
'--forceInclude .chapter__buttons',
'--output _includes/critical.css'
].join(' '),
}
}
}