2019-03-03 04:02:06 +01:00
|
|
|
const svgs = require('../bin/svgs')
|
2019-09-21 08:17:52 +02:00
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
const $ = require('cheerio')
|
2019-03-03 04:02:06 +01:00
|
|
|
|
|
|
|
const inlineSvgs = svgs.filter(_ => _.inline).map(_ => `#${_.id}`)
|
2019-09-21 08:17:52 +02:00
|
|
|
const allSvgs = {}
|
|
|
|
const $inlineHtml = $(fs.readFileSync(path.join(__dirname, '../src/template.html'), 'utf8'))
|
|
|
|
const $externalSvgs = $(fs.readFileSync(path.join(__dirname, '../static/icons.svg'), 'utf8'))
|
|
|
|
svgs.forEach(_ => {
|
|
|
|
const $inlineSvg = $inlineHtml.find(`#${_.id}`)
|
|
|
|
const $svg = $inlineSvg.length ? $inlineSvg : $externalSvgs.find(`#${_.id}`)
|
|
|
|
|
|
|
|
allSvgs[`#${_.id}`] = {
|
|
|
|
viewBox: $svg.attr('viewBox'),
|
|
|
|
html: $svg.html()
|
|
|
|
}
|
|
|
|
})
|
2019-03-03 04:02:06 +01:00
|
|
|
const mode = process.env.NODE_ENV || 'production'
|
2018-12-16 04:21:20 +01:00
|
|
|
const dev = mode === 'development'
|
|
|
|
|
2018-12-18 09:43:51 +01:00
|
|
|
const resolve = {
|
|
|
|
extensions: ['.js', '.json', '.html'],
|
2020-11-29 23:13:27 +01:00
|
|
|
mainFields: ['svelte', 'module', 'browser', 'main'],
|
|
|
|
alias: {
|
2021-02-16 00:07:19 +01:00
|
|
|
// All browsers we target support Intl.PluralRules (or it's polyfilled).
|
|
|
|
// So format-message-interpret can fall back to that. This file is pretty big (9.83kB) and it's not needed.
|
2020-12-21 00:33:41 +01:00
|
|
|
'./plurals': 'lodash-es/noop',
|
|
|
|
'lookup-closest-locale': 'lodash-es/noop' // small, but also not needed
|
2020-11-29 23:13:27 +01:00
|
|
|
}
|
2018-12-18 09:43:51 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 04:21:20 +01:00
|
|
|
module.exports = {
|
|
|
|
mode,
|
2018-12-18 09:43:51 +01:00
|
|
|
dev,
|
2019-03-03 04:02:06 +01:00
|
|
|
resolve,
|
2019-09-21 08:17:52 +02:00
|
|
|
inlineSvgs,
|
|
|
|
allSvgs
|
2018-12-16 04:21:20 +01:00
|
|
|
}
|