1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/development/build/static.js
Mark Stacey b30a352acb
Use @fortawesome/fontawesome-free npm package (#8256)
The official npm package for Font Awesome Free is now used instead of
the vendored styles. Previously we had been using v4.4.0, now we're
using v5.13.0.

We're now importing the Font Awesome SCSS modules instead of using the
minified CSS bundle. This integrates more cleanly into our build
system, and it lets us use their mixins directly in the future if we
need to.

The variable `fa-font-path` has been set to reference our font
directory, as instructed here:
https://fontawesome.com/how-to-use/on-the-web/using-with/sass#compile
2020-03-30 20:05:51 -03:00

100 lines
2.2 KiB
JavaScript

const fs = require('fs-extra')
const path = require('path')
const watch = require('gulp-watch')
const glob = require('fast-glob')
const { createTask, composeSeries } = require('./task')
module.exports = createStaticAssetTasks
const copyTargets = [
{
src: `./app/_locales/`,
dest: `_locales`,
},
{
src: `./app/images/`,
dest: `images`,
},
{
src: `./node_modules/eth-contract-metadata/images/`,
dest: `images/contract`,
},
{
src: `./app/fonts/`,
dest: `fonts`,
},
{
src: `./app/vendor/`,
dest: `vendor`,
},
{
src: `./node_modules/@fortawesome/fontawesome-free/webfonts/`,
dest: `fonts/fontawesome`,
},
{
src: `./ui/app/css/output/`,
pattern: `*.css`,
dest: ``,
},
{
src: `./app/`,
pattern: `*.html`,
dest: ``,
},
]
const copyTargetsDev = [
...copyTargets,
{
src: './app/scripts/',
pattern: '/chromereload.js',
dest: ``,
},
]
function createStaticAssetTasks ({ livereload, browserPlatforms }) {
const prod = createTask('static:prod', composeSeries(...copyTargets.map((target) => {
return async function copyStaticAssets () {
await performCopy(target)
}
})))
const dev = createTask('static:dev', composeSeries(...copyTargetsDev.map((target) => {
return async function copyStaticAssets () {
await setupLiveCopy(target)
}
})))
return { dev, prod }
async function setupLiveCopy (target) {
const pattern = target.pattern || '/**/*'
watch(target.src + pattern, (event) => {
livereload.changed(event.path)
performCopy(target)
})
await performCopy(target)
}
async function performCopy (target) {
await Promise.all(browserPlatforms.map(async (platform) => {
if (target.pattern) {
await copyGlob(target.src, `${target.src}${target.pattern}`, `./dist/${platform}/${target.dest}`)
} else {
await copyGlob(target.src, `${target.src}`, `./dist/${platform}/${target.dest}`)
}
}))
}
async function copyGlob (baseDir, srcGlob, dest) {
const sources = await glob(srcGlob, { onlyFiles: false })
await Promise.all(sources.map(async (src) => {
const relativePath = path.relative(baseDir, src)
await fs.copy(src, `${dest}${relativePath}`)
}))
}
}