2019-03-03 03:02:06 +00:00
|
|
|
const svgs = require('../bin/svgs')
|
2019-09-21 06:17:52 +00:00
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
const $ = require('cheerio')
|
2019-03-03 03:02:06 +00:00
|
|
|
|
|
|
|
const inlineSvgs = svgs.filter(_ => _.inline).map(_ => `#${_.id}`)
|
2019-09-21 06:17:52 +00: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 03:02:06 +00:00
|
|
|
const mode = process.env.NODE_ENV || 'production'
|
2018-12-16 03:21:20 +00:00
|
|
|
const dev = mode === 'development'
|
|
|
|
|
2018-12-18 08:43:51 +00:00
|
|
|
const resolve = {
|
|
|
|
extensions: ['.js', '.json', '.html'],
|
|
|
|
mainFields: ['svelte', 'module', 'browser', 'main'],
|
|
|
|
alias: {
|
2019-08-03 20:49:37 +00:00
|
|
|
react: 'preact/compat/dist/compat.module.js',
|
2019-09-21 06:17:52 +00:00
|
|
|
'react-dom': 'preact/compat/dist/compat.module.js',
|
|
|
|
...(process.env.LEGACY ? {
|
|
|
|
'../_utils/tesseractWorker.js': 'lodash/noop',
|
|
|
|
'emoji-mart/dist-modern/components/picker/nimble-picker': 'emoji-mart/dist-es/components/picker/nimble-picker',
|
|
|
|
'emoji-regex/es2015/text': 'emoji-regex/text',
|
|
|
|
'page-lifecycle/dist/lifecycle.mjs': 'page-lifecycle/dist/lifecycle.es5.js',
|
|
|
|
'./SvgIcon.html': './SvgIconLegacy.html',
|
|
|
|
'../SvgIcon.html': '../SvgIconLegacy.html',
|
|
|
|
'../../SvgIcon.html': '../../SvgIconLegacy.html',
|
|
|
|
'../../_components/SvgIcon.html': '../../_components/SvgIconLegacy.html',
|
|
|
|
'../../../_components/SvgIcon.html': '../../../_components/SvgIconLegacy.html'
|
|
|
|
} : {
|
2020-06-29 06:12:14 +00:00
|
|
|
// these polyfills are only needed in legacy mode
|
|
|
|
'array-flat-polyfill': 'lodash/noop',
|
|
|
|
'indexeddb-getall-shim': 'lodash/noop',
|
2019-10-27 18:11:57 +00:00
|
|
|
intl: 'lodash/noop',
|
2020-06-29 06:12:14 +00:00
|
|
|
'intersection-observer': 'lodash/noop',
|
|
|
|
'@webcomponents/custom-elements': 'lodash/noop',
|
|
|
|
'@webcomponents/shadydom': 'lodash/noop',
|
2019-10-27 18:11:57 +00:00
|
|
|
'./routes/_thirdparty/regenerator-runtime/runtime.js': 'lodash/noop',
|
|
|
|
'../_thirdparty/regenerator-runtime/runtime.js': 'lodash/noop'
|
2019-09-21 06:17:52 +00:00
|
|
|
})
|
2018-12-18 08:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 03:21:20 +00:00
|
|
|
module.exports = {
|
|
|
|
mode,
|
2018-12-18 08:43:51 +00:00
|
|
|
dev,
|
2019-03-03 03:02:06 +00:00
|
|
|
resolve,
|
2019-09-21 06:17:52 +00:00
|
|
|
inlineSvgs,
|
|
|
|
allSvgs
|
2018-12-16 03:21:20 +00:00
|
|
|
}
|