Added support for web font minification in production

This commit is contained in:
squidfunk 2018-06-18 10:11:54 +02:00
parent f9298cf91f
commit 380631b974
5 changed files with 21 additions and 2942 deletions

File diff suppressed because one or more lines are too long

View File

@ -10,15 +10,4 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
* SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND * SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
* LIMITATIONS UNDER THE LICENSE. * LIMITATIONS UNDER THE LICENSE.
*/ */@font-face{font-family:"Material Icons";font-style:normal;font-weight:400;src:local("Material Icons"),local("MaterialIcons-Regular"),url("specimen/MaterialIcons-Regular.woff2") format("woff2"),url("specimen/MaterialIcons-Regular.woff") format("woff"),url("specimen/MaterialIcons-Regular.ttf") format("truetype")}
@font-face {
font-family: "Material Icons";
font-style: normal;
font-weight: 400;
src: local("Material Icons"),
local("MaterialIcons-Regular"),
url("specimen/MaterialIcons-Regular.woff2") format("woff2"),
url("specimen/MaterialIcons-Regular.woff") format("woff"),
url("specimen/MaterialIcons-Regular.ttf") format("truetype");
}

6
package-lock.json generated
View File

@ -2541,6 +2541,12 @@
"integrity": "sha1-yBSQPkViM3GgR3tAEJqq++6t27Q=", "integrity": "sha1-yBSQPkViM3GgR3tAEJqq++6t27Q=",
"dev": true "dev": true
}, },
"cssmin": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/cssmin/-/cssmin-0.4.3.tgz",
"integrity": "sha1-yRlAd+Dr2s1pHV9ZAVudgZ840BU=",
"dev": true
},
"cssnano": { "cssnano": {
"version": "3.10.0", "version": "3.10.0",
"resolved": "https://registry.npmjs.org/cssnano/-/cssnano-3.10.0.tgz", "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-3.10.0.tgz",

View File

@ -44,6 +44,7 @@
"copy-webpack-plugin": "^4.2.1", "copy-webpack-plugin": "^4.2.1",
"css-loader": "^0.28.7", "css-loader": "^0.28.7",
"css-mqpacker": "^6.0.1", "css-mqpacker": "^6.0.1",
"cssmin": "^0.4.3",
"custom-event-polyfill": "^0.3.0", "custom-event-polyfill": "^0.3.0",
"customizr": "^1.0.0-alpha", "customizr": "^1.0.0-alpha",
"escape-string-regexp": "^1.0.5", "escape-string-regexp": "^1.0.5",

View File

@ -21,6 +21,7 @@
*/ */
const fs = require("fs") const fs = require("fs")
const cssmin = require("cssmin")
const path = require("path") const path = require("path")
const html = require("html-minifier") const html = require("html-minifier")
const uglify = require("uglify-js") const uglify = require("uglify-js")
@ -40,7 +41,7 @@ const ManifestPlugin = require("webpack-manifest-plugin")
* Configuration * Configuration
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
module.exports = env => { module.exports = env => { // eslint-disable-line complexity
const config = { const config = {
/* Entrypoints */ /* Entrypoints */
@ -122,10 +123,18 @@ module.exports = env => {
} }
}, },
/* Copy web fonts */ /* Copy web font files */
{ {
context: "src", context: "src",
from: "assets/fonts/**/*" from: "assets/fonts/**/*",
ignore: "**/*.css"
},
/* Copy and minify web font stylesheets */
{
context: "src",
from: "assets/fonts/*.css",
transform: content => cssmin(content.toString())
}, },
/* Copy images without cache busting */ /* Copy images without cache busting */