build: use raw octicons

This commit is contained in:
EnixCoda 2019-11-08 15:44:58 +08:00
parent 4256211dbe
commit a03d28bcd6
No known key found for this signature in database
GPG key ID: FE06F5DFC1C9B8E4
6 changed files with 8 additions and 44 deletions

1
.gitignore vendored
View file

@ -3,5 +3,4 @@
node_modules
tmp
dist
src/assets/icons/octicons
yarn-error.log

View file

@ -15,7 +15,7 @@
"roll": "./scripts/release.sh"
},
"dependencies": {
"@primer/octicons": "^9.1.1",
"@primer/octicons": "^9.2.0",
"@primer/octicons-react": "^9.2.0",
"@sentry/browser": "^5.5.0",
"@types/firefox-webext-browser": "^70.0.1",

View file

@ -1,34 +0,0 @@
const octicons = require('@primer/octicons')
const fs = require('fs')
const path = require('path')
const pathToIconsFolder = path.resolve(__dirname, `../src/assets/icons/octicons`)
function generateIconSVGFiles() {
Object.values(octicons).forEach(icon => {
fs.writeFile(
`${pathToIconsFolder}/${icon.symbol}.svg`,
icon.toSVG({ xmlns: 'http://www.w3.org/2000/svg' }),
err => {
if (err) throw err
},
)
})
}
fs.exists(pathToIconsFolder, exists => {
if (exists) {
fs.lstat(pathToIconsFolder, (err, stats) => {
if (err) throw err
if (!stats.isDirectory()) {
throw new Error(`${pathToIconsFolder} is not a folder!`)
}
generateIconSVGFiles()
})
} else {
fs.mkdir(pathToIconsFolder, err => {
if (err) throw err
generateIconSVGFiles()
})
}
})

View file

@ -56,18 +56,18 @@
width: 100%;
height: 100%;
display: block;
background-image: url('./assets/icons/octicons/clippy.svg?inline');
background-image: url('~@primer/octicons/build/svg/clippy.svg?inline');
background-position: center;
background-repeat: no-repeat;
}
&.success {
.icon {
background-image: url('./assets/icons/octicons/check.svg?inline');
background-image: url('~@primer/octicons/build/svg/check.svg?inline');
}
}
&.fail {
.icon {
background-image: url('./assets/icons/octicons/x.svg?inline');
background-image: url('~@primer/octicons/build/svg/x.svg?inline');
}
}
}

View file

@ -81,7 +81,6 @@ module.exports = {
test: /\.svg$/,
resourceQuery: /inline/,
loader: ['url-loader'],
include: [srcPath],
},
{
test: /\.json$/,

View file

@ -810,10 +810,10 @@
dependencies:
prop-types "^15.6.1"
"@primer/octicons@^9.1.1":
version "9.1.1"
resolved "https://registry.yarnpkg.com/@primer/octicons/-/octicons-9.1.1.tgz#a72a59e8ec77521cc2eefb36c345f780a61c79fb"
integrity sha512-7EGM0+Kx39bIgaYr9bTCzFvBCxm+fqh/YJIoSns8zfCwss32ZJ2GDP3024UH709VQtM5cKFU4JcIYPHyGdSfIg==
"@primer/octicons@^9.2.0":
version "9.2.0"
resolved "https://registry.yarnpkg.com/@primer/octicons/-/octicons-9.2.0.tgz#705783d57335c4ffbde4650e4d22302947208c6e"
integrity sha512-3vv7bBqVUHhU7ChpmQhmzz3WmHEKKSk9z/xEK5KnU8Egh96RoqKIim07geRj825ISa+IWj9cPdOA1ShqW5k3Yw==
dependencies:
object-assign "^4.1.1"