style: remove font files in default css index bundle

This commit is contained in:
07akioni 2020-06-01 12:38:10 +08:00
parent 86f2b5cfb6
commit d47342af8b
10 changed files with 121 additions and 68 deletions

View File

@ -9,6 +9,12 @@ const styleFiles = fs
.readdirSync(path.resolve(__dirname, '../src/_styles'))
.filter(fileName => fileName.endsWith('.scss'))
const fontStyleFiles = fs
.readdirSync(path.resolve(__dirname, '../src/_styles/fonts'))
.filter(fileName => {
return ['Lato.scss', 'FiraSans.scss', 'FiraCode.scss'].includes(fileName)
})
function createDirIfNotExists (...args) {
if (!fs.existsSync(path.resolve(...args))) {
fs.mkdirSync(path.resolve(...args))
@ -17,14 +23,20 @@ function createDirIfNotExists (...args) {
createDirIfNotExists(__dirname, '../lib')
createDirIfNotExists(__dirname, '../lib', 'styles')
createDirIfNotExists(__dirname, '../lib', 'styles', 'fonts')
createDirIfNotExists(__dirname, '../lib', 'styles', 'resources')
createDirIfNotExists(__dirname, '../es')
createDirIfNotExists(__dirname, '../es', 'styles')
createDirIfNotExists(__dirname, '../es', 'styles', 'fonts')
createDirIfNotExists(__dirname, '../es', 'styles', 'resources')
styleFiles.forEach(fileName => {
function createStyleGenerator (
srcPath,
targetPath
) {
return fileName => {
sass.render({
file: path.resolve(__dirname, '../src/_styles', fileName),
file: path.resolve(__dirname, '../src/' + srcPath, fileName),
outputStyle: 'expanded'
}, function (err, sassResult) {
if (err) console.error(err)
@ -34,14 +46,14 @@ styleFiles.forEach(fileName => {
})
.then(result => {
fs.writeFile(
path.resolve(__dirname, '../lib/styles', fileName.replace(/\.scss/, '.css')),
path.resolve(__dirname, '../lib/' + targetPath, fileName.replace(/\.scss/, '.css')),
result.css,
err => {
if (err) console.error(err)
}
)
fs.writeFile(
path.resolve(__dirname, '../es/styles', fileName.replace(/\.scss/, '.css')),
path.resolve(__dirname, '../es/' + targetPath, fileName.replace(/\.scss/, '.css')),
result.css,
err => {
if (err) console.error(err)
@ -49,7 +61,11 @@ styleFiles.forEach(fileName => {
)
})
})
})
}
}
styleFiles.forEach(createStyleGenerator('_styles', 'styles'))
fontStyleFiles.forEach(createStyleGenerator('_styles/fonts', 'styles/fonts'))
ncp(
path.resolve(__dirname, '../src/_styles/resources'),

View File

@ -9,6 +9,12 @@ const styleFiles = fs
.readdirSync(path.resolve(__dirname, '../src/_styles'))
.filter(fileName => fileName.endsWith('.scss'))
const fontStyleFiles = fs
.readdirSync(path.resolve(__dirname, '../src/_styles/fonts'))
.filter(fileName => {
return ['Lato.scss', 'FiraSans.scss', 'FiraCode.scss'].includes(fileName)
})
function createDirIfNotExists (...args) {
if (!fs.existsSync(path.resolve(...args))) {
fs.mkdirSync(path.resolve(...args))
@ -17,14 +23,20 @@ function createDirIfNotExists (...args) {
createDirIfNotExists(__dirname, '../lib')
createDirIfNotExists(__dirname, '../lib', 'styles')
createDirIfNotExists(__dirname, '../lib', 'styles', 'fonts')
createDirIfNotExists(__dirname, '../lib', 'styles', 'resources')
createDirIfNotExists(__dirname, '../es')
createDirIfNotExists(__dirname, '../es', 'styles')
createDirIfNotExists(__dirname, '../es', 'styles', 'fonts')
createDirIfNotExists(__dirname, '../es', 'styles', 'resources')
styleFiles.forEach(fileName => {
function createStyleGenerator (
srcPath,
targetPath
) {
return fileName => {
sass.render({
file: path.resolve(__dirname, '../src/_styles', fileName),
file: path.resolve(__dirname, '../src/' + srcPath, fileName),
outputStyle: 'expanded'
}, function (err, sassResult) {
if (err) console.error(err)
@ -34,14 +46,14 @@ styleFiles.forEach(fileName => {
})
.then(result => {
fs.writeFile(
path.resolve(__dirname, '../lib/styles', fileName.replace(/\.scss/, '.css')),
path.resolve(__dirname, '../lib/' + targetPath, fileName.replace(/\.scss/, '.css')),
result.css,
err => {
if (err) console.error(err)
}
)
fs.writeFile(
path.resolve(__dirname, '../es/styles', fileName.replace(/\.scss/, '.css')),
path.resolve(__dirname, '../es/' + targetPath, fileName.replace(/\.scss/, '.css')),
result.css,
err => {
if (err) console.error(err)
@ -49,7 +61,11 @@ styleFiles.forEach(fileName => {
)
})
})
})
}
}
styleFiles.forEach(createStyleGenerator('_styles', 'styles'))
fontStyleFiles.forEach(createStyleGenerator('_styles/fonts', 'styles/fonts'))
ncp(
path.resolve(__dirname, '../src/_styles/resources'),

View File

@ -3,6 +3,8 @@ import hljs from './hljs'
import demoRouterView from './demoRouterView'
import NaiveUI from '../lib/index'
import '../lib/styles/index.css'
import '../lib/styles/fonts/Lato.css'
import '../lib/styles/fonts/FiraSans.css'
import createRouter from './routes/router'
import { routes } from './routes/routes'

View File

@ -5,6 +5,8 @@ import hljs from './hljs'
import demoRouterView from './demoRouterView'
import NaiveUI from '../src/index'
import '../src/_styles/index.scss'
import '../src/_styles/fonts/Lato.scss'
import '../src/_styles/fonts/FiraCode.scss'
import { routes, childRoutes } from './routes/routes'
import createRouter from './routes/router'

View File

@ -4,7 +4,6 @@
@include b(log) {
@include once {
position: relative;
font-family: $--n-mono-font-family;
font-size: 14px;
box-sizing: border-box;
transition:
@ -15,6 +14,7 @@
white-space: pre-wrap;
}
@include e(line) {
font-family: $--n-mono-font-family;
margin: 0;
}
}
@ -22,7 +22,6 @@
@include b(log-loader) {
@include once {
@include fade-in-width-expand-transition($duration: .3s, $delay: 0s);
font-family: $--n-font-family;
transition:
color .3s $--n-ease-in-out-cubic-bezier,
background-color .3s $--n-ease-in-out-cubic-bezier;

View File

@ -1,5 +1,3 @@
@import './fonts/FiraCode.scss';
@import './fonts/Lato.scss';
@import './themes/common.scss';
@import './themes/light/index.scss';
@import './mixins/mixins.scss';

View File

@ -1,5 +1,5 @@
@font-face {
font-family: 'FiraCode';
font-weight: 400;
src: url('./resources/fonts/FiraCode-Regular.woff2');
src: url('../resources/fonts/FiraCode-Regular.woff2');
}

View File

@ -1,11 +1,21 @@
@import '../themes/common.scss';
@font-face {
font-family: 'FiraSans';
font-weight: 400;
src: url('./resources/fonts/FiraSans-Regular.woff2');
src: url('../resources/fonts/FiraSans-Regular.woff2');
}
@font-face {
font-family: 'FiraSans';
font-weight: 600;
src: url('./resources/fonts/FiraSans-Medium.woff2');
font-weight: 500;
src: url('../resources/fonts/FiraSans-Medium.woff2');
}
body {
font-family: 'FiraSans', $--n-font-family;
}
input {
font-family: 'FiraSans', $--n-font-family;
}

View File

@ -1,11 +1,21 @@
@import '../themes/common.scss';
@font-face {
font-family: 'Lato';
font-weight: 400;
src: url('./resources/fonts/LatoLatin-Regular.woff2');
src: url('../resources/fonts/LatoLatin-Regular.woff2');
}
@font-face {
font-family: 'Lato';
font-weight: 500;
src: url('./resources/fonts/LatoLatin-Semibold.woff2');
src: url('../resources/fonts/LatoLatin-Semibold.woff2');
}
body {
font-family: 'Lato', $--n-font-family;
}
input {
font-family: 'Lato', $--n-font-family;
}

View File

@ -1,5 +1,5 @@
$--n-font-family: Lato, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
$--n-mono-font-family: FiraCode, monospace;
$--n-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
$--n-mono-font-family: FiraCode, SFMono-Regular, Menlo, Consolas, Courier, monospace;
$--n-strong-weight: 500;