提交 53119b63 编写于 作者: H hdx

fix(theme): 撤回对 uni.scss 的支持

上级 c8144165
...@@ -2,7 +2,6 @@ import path from 'path' ...@@ -2,7 +2,6 @@ import path from 'path'
import fs from 'fs-extra' import fs from 'fs-extra'
import { import {
PAGES_JSON_UTS, PAGES_JSON_UTS,
ThemeSassParser,
createRollupError, createRollupError,
genUTSClassName, genUTSClassName,
normalizeUniAppXAppPagesJson, normalizeUniAppXAppPagesJson,
...@@ -44,6 +43,7 @@ export function uniAppPagesPlugin(): Plugin { ...@@ -44,6 +43,7 @@ export function uniAppPagesPlugin(): Plugin {
transform(code, id) { transform(code, id) {
if (isPages(id)) { if (isPages(id)) {
this.addWatchFile(path.resolve(process.env.UNI_INPUT_DIR, 'pages.json')) this.addWatchFile(path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'))
this.addWatchFile(path.resolve(process.env.UNI_INPUT_DIR, 'theme.json'))
let pagesJson: UniApp.PagesJson = { let pagesJson: UniApp.PagesJson = {
pages: [], pages: [],
globalStyle: { globalStyle: {
...@@ -110,7 +110,7 @@ export function uniAppPagesPlugin(): Plugin { ...@@ -110,7 +110,7 @@ export function uniAppPagesPlugin(): Plugin {
launchPage = stringifyLaunchPage(pagesJson.pages[0]) launchPage = stringifyLaunchPage(pagesJson.pages[0])
// theme.json // theme.json
themeConfig = readUniSassAsStringifyMap() themeConfig = readThemeJSONFileAsStringifyMap()
return { return {
code: `${imports.map((p) => `import './${p}.uvue'`).join('\n')} code: `${imports.map((p) => `import './${p}.uvue'`).join('\n')}
export default 'pages.json'`, export default 'pages.json'`,
...@@ -165,13 +165,22 @@ function stringifyPageStyle(pageStyle: UniApp.PagesJsonPageStyle) { ...@@ -165,13 +165,22 @@ function stringifyPageStyle(pageStyle: UniApp.PagesJsonPageStyle) {
return stringifyMap(pageStyle) return stringifyMap(pageStyle)
} }
function readUniSassAsStringifyMap() { // function readUniSassAsStringifyMap() {
const uniScssPath = path.resolve(process.env.UNI_INPUT_DIR, 'uni.scss') // const uniScssPath = path.resolve(process.env.UNI_INPUT_DIR, 'uni.scss')
let result = {} // let result = {}
if (fs.existsSync(uniScssPath)) { // if (fs.existsSync(uniScssPath)) {
const content = fs.readFileSync(uniScssPath, 'utf8') // const content = fs.readFileSync(uniScssPath, 'utf8')
const parser = new ThemeSassParser() // const parser = new ThemeSassParser()
result = parser.parse(content) // result = parser.parse(content)
// }
// return stringifyMap(result)
// }
function readThemeJSONFileAsStringifyMap() {
const themeJsonPath = path.resolve(process.env.UNI_INPUT_DIR, 'theme.json')
let content = '{}'
if (fs.existsSync(themeJsonPath)) {
content = fs.readFileSync(themeJsonPath, 'utf8')
} }
return stringifyMap(result) return stringifyMap(JSON.parse(content))
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册