Pinafore-Web-Client-Frontend/webpack/shared.config.js

34 lines
906 B
JavaScript
Raw Normal View History

const svgs = require('../bin/svgs')
const fs = require('fs')
const path = require('path')
const $ = require('cheerio')
const inlineSvgs = svgs.filter(_ => _.inline).map(_ => `#${_.id}`)
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()
}
})
const mode = process.env.NODE_ENV || 'production'
const dev = mode === 'development'
const resolve = {
extensions: ['.js', '.json', '.html'],
2020-09-13 22:37:54 +02:00
mainFields: ['svelte', 'module', 'browser', 'main']
}
module.exports = {
mode,
dev,
resolve,
inlineSvgs,
allSvgs
}