提交 a6d21955 编写于 作者: 雪洛's avatar 雪洛

feat: import @/pages.json

上级 c6530ada
......@@ -8,11 +8,11 @@ const {
getPartialIdentifier
} = require('./util')
function resolve (dir) {
function resolve(dir) {
return path.resolve(__dirname, '..', dir)
}
module.exports = function chainWebpack (platformOptions, vueOptions, api) {
module.exports = function chainWebpack(platformOptions, vueOptions, api) {
const {
runByHBuilderX, // 使用 HBuilderX 运行
cssPreprocessOptions
......@@ -150,5 +150,15 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
if (process.env.BUILD_ENV === 'ali-ide') {
webpackConfig.plugins.delete('progress')
}
webpackConfig.resolve.alias
.delete('@')
.set(
'@/pages.json',
path.resolve(process.env.UNI_INPUT_DIR, 'pages.json')
+ '?' + JSON.stringify({
type: 'origin-pages-json'
})
)
.set('@', path.resolve(process.env.UNI_INPUT_DIR))
}
}
......@@ -84,6 +84,15 @@ module.exports = function (content, map) {
process.exit(0)
}
if (this.resourceQuery) {
const queryParam = loaderUtils.parseQuery(this.resourceQuery)
if (queryParam) {
if (queryParam.type === 'origin-pages-json') {
return `export default ${JSON.stringify(pagesJson)}`
}
}
}
if (global.uniPlugin.defaultTheme) {
pagesJson = parseTheme(pagesJson)
this.addDependency(path.resolve(process.env.UNI_INPUT_DIR, 'theme.json'))
......
......@@ -31,12 +31,13 @@ function checkEmitFile (filePath, jsonObj, changedEmitFiles) {
module.exports = function (content, map) {
// content = JSON.stringify(require('@dcloudio/uni-cli-shared/lib/uni_modules').getPagesJson(content))
let queryParam
if (this.resourceQuery) {
const params = loaderUtils.parseQuery(this.resourceQuery)
if (params) {
if (params.type === 'style') {
queryParam = loaderUtils.parseQuery(this.resourceQuery)
if (queryParam) {
if (queryParam.type === 'style') {
return `export default ${JSON.stringify(getPagesJson())}`
} else if (params.type === 'stat') {
} else if (queryParam.type === 'stat') {
return `export default ${JSON.stringify(process.UNI_STAT_CONFIG || {})}`
}
}
......@@ -73,6 +74,14 @@ module.exports = function (content, map) {
}
})
if (this.resourceQuery && queryParam) {
if (queryParam) {
if (queryParam.type === 'origin-pages-json') {
return `export default ${JSON.stringify(pagesJson)}`
}
}
}
if (manifestJson.transformPx === false) {
process.UNI_TRANSFORM_PX = false
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册