修复打包

pull/1/head 1.0.0
yutent 2023-05-15 15:17:55 +08:00
parent 5d9f768f1e
commit 927aaa5bc9
4 changed files with 26 additions and 9 deletions

View File

@ -113,7 +113,7 @@ export function compileScss(file, mini = true) {
return scss.compileString(file, { style, ...OPTIONS }).css.trim()
}
} catch (err) {
console.log('compile scss: ', file)
// console.log('compile scss: ', file)
console.error(err)
}
}
@ -212,7 +212,7 @@ export function parseJs(
.replace(/import (["'])(.*?)\1/g, function (m, q, name) {
if (name.endsWith('.css') || name.endsWith('.scss')) {
if (name.startsWith('@/')) {
name = name.replace('@/', '/')
name = name.replace('@/', urlJoin(DEPLOY_PATH, ASSETS_DIR))
}
if (isBuild) {

View File

@ -4,9 +4,9 @@
* @date 2022/09/06 11:54:56
*/
export const JS_EXP = /<script[^>]*?>([\w\W]*?)<\/script>/
export const STYLE_EXP = /<style([^>]*?)>([\w\W]*?)<\/style>/g
export const HTML_EXP = /<template[^>]*?>([\w\W]*?)\n<\/template>/
export const JS_EXP = /(?<=\n|^)<script[^>]*?>([\w\W]*?)<\/script>/
export const STYLE_EXP = /(?<=\n|^)<style([^>]*?)>([\w\W]*?)<\/style>/g
export const HTML_EXP = /(?<=\n|^)<template[^>]*?>([\w\W]*?)\n<\/template>/
export const V_DEEP = /:deep\(([^)]*?)\)(.*)/
export const CSS_SHEET_EXP = /([%@\w\.,#\-:>\+\~\|\(\)\[\]"'\=\s]+)\{/g

View File

@ -9,6 +9,7 @@ export default function compile(root = '', dist = '', conf = {}) {
const PUBLIC_DIR = join(root, 'public')
const DEPLOY_PATH = conf.base || '' // 部署目录, 默认是根目录部署
const IS_MPA = Object.keys(conf.pages).length > 1
const PAGES_PREFIX = Object.keys(conf.pages).map(it => `pages/${it}/`)
let timeStart = Date.now()
let template = fs.cat(join(process.env.PWD, 'index.html')).toString()
@ -20,7 +21,21 @@ export default function compile(root = '', dist = '', conf = {}) {
path: it,
ext: parse(it).ext
}))
.filter(it => fs.isfile(it.path) && it.ext !== '')
.filter(it => {
if (fs.isfile(it.path) && it.ext !== '') {
if (IS_MPA && it.name.startsWith('pages/')) {
if (PAGES_PREFIX.some(it => it.startsWith(it.name))) {
return true
} else {
return false
}
}
return true
}
return false
})
let compileFiles = function (currentPage, page, files) {
let options = { IS_MPA, currentPage, SOURCE_DIR, DEPLOY_PATH }
@ -113,7 +128,7 @@ export default function compile(root = '', dist = '', conf = {}) {
if (fs.isdir(it)) {
return
}
let idx = list.findIndex(_ => _.path === it)
let idx = list.findIndex(_ => _?.path === it)
let name = it.slice(dir.length + 1)
let ext = parse(name).ext
@ -121,7 +136,7 @@ export default function compile(root = '', dist = '', conf = {}) {
return
}
list.splice(idx, 1)
list[idx] = null
files.push({
name,
@ -134,6 +149,8 @@ export default function compile(root = '', dist = '', conf = {}) {
compileFiles(currentPage, page, files)
}
list = list.filter(it => it)
if (IS_MPA) {
console.log('\n正在解析公共依赖 ...')
compileFiles('', null, list)

View File

@ -1,7 +1,7 @@
{
"name": "fite",
"type": "module",
"version": "0.9.4",
"version": "1.0.0",
"bin": {
"fite": "index.js"
},