提交 d529a6e3 编写于 作者: fxy060608's avatar fxy060608

wip(app): nvue

上级 db4f8169
......@@ -19,13 +19,15 @@ function runWebpack(mode, options) {
if (stats.hasErrors()) {
return reject(stats.toString());
}
const info = stats.toJson();
if (stats.hasWarnings()) {
const info = stats.toJson({ all: false, warnings: true });
console.warn(info.warnings);
}
console.log(stats.toString({
chunks: true,
colors: true, // 在控制台展示颜色
all: false,
assets: true,
colors: true,
timings: true,
}));
resolve(void 0);
});
......
......@@ -54,22 +54,9 @@ exports.default = (options) => {
// So all leading spaces must be eliminated to avoid problems.
selector.first.spaces.before = '';
}
// fixed by xxxxxx (h5,app-plus v3 平台继续使用 attribute,其他平台使用 className)
if(
process.env.UNI_PLATFORM === 'h5' ||
(
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V3
)
){
selector.insertAfter(node, selectorParser.attribute({
attribute: id
}));
} else {
selector.insertAfter(node, selectorParser.className({
value: id
}));
}
});
}).processSync(node.selector);
});
......
......@@ -87,20 +87,15 @@ module.exports = function genStyleInjectionCode (
})
} else {// fixed by xxxxxx nvue style
styleInjectionCode = `if(!this.options.style){this.options.style = {}}
if(Vue.prototype.__merge_style && Vue.prototype.__$appStyle__){Vue.prototype.__merge_style(Vue.prototype.__$appStyle__, this.options.style)}
Vue.prototype.__merge_style(Vue.prototype.__$appStyle__, this.options.style)
`
styles.forEach((style, i) => {
if (isNotEmptyStyle(style)) {
const request = genStyleRequest(style, i)
styleInjectionCode += (
`if(Vue.prototype.__merge_style){
Vue.prototype.__merge_style(require(${request}).default, this.options.style)
}else{
Object.assign(this.options.style,require(${request}).default)
}\n`//fixed by xxxxxx 简单处理,与 weex-vue-loader 保持一致
styleInjectionCode += `Vue.prototype.__merge_style(require(${request}).default, this.options.style)\n`
//fixed by xxxxxx 简单处理,与 weex-vue-loader 保持一致
//`var style${i} = require(${request})\n` +
//`if (style${i}.__inject__) style${i}.__inject__(context)\n`
)
if (style.module) genCSSModulesCode(style, request, i)
}
})
......
......@@ -174,7 +174,7 @@ var EXTENDED_COLOR_KEYWORDS = {
var LENGTH_REGEXP = /^[-+]?\d*\.?\d+(\S*)$/
var SUPPORT_CSS_UNIT = ['px', 'pt', 'wx']
if(process.env.UNI_USING_NVUE_COMPILER){
if(process.env.UNI_NVUE_COMPILER === 'uni-app'){
SUPPORT_CSS_UNIT.push('upx')
SUPPORT_CSS_UNIT.push('rpx')
}
......
......@@ -4930,7 +4930,7 @@ function genDefaultModel (
var event = lazy ? 'change' : 'input';
var valueExpression = "$event.target.attr.value" + (trim ? '.trim()' : '');
if(process.env.UNI_USING_NVUE_COMPILER){
if(process.env.UNI_NVUE_COMPILER === 'uni-app'){
valueExpression = "$event.detail.value" + (trim ? '.trim()' : '');
}
if (number) {
......
......@@ -20,14 +20,17 @@ function runWebpack(
if (stats!.hasErrors()) {
return reject(stats!.toString())
}
const info = stats!.toJson()
if (stats!.hasWarnings()) {
const info = stats!.toJson({ all: false, warnings: true })
console.warn(info.warnings)
}
console.log(
stats!.toString({
chunks: true, // 使构建过程更静默无输出
all: false,
assets: true,
colors: true, // 在控制台展示颜色
timings: true,
})
)
resolve(void 0)
......
......@@ -6,22 +6,22 @@ export function initWebpackNVueEntry(pages: UniApp.PagesJsonPageOptions[]) {
process.UNI_NVUE_ENTRY = {}
pages.forEach((page) => {
if (page.style.isNVue) {
process.UNI_NVUE_ENTRY[page.path] = genWebpackBase64Code(page.path)
process.UNI_NVUE_ENTRY[page.path] = genWebpackBase64Code(
genNVueEntryCode(page.path)
)
}
})
}
function genWebpackBase64Code(route: string) {
return `data:text/javascript;base64,${Buffer.from(
genNVueEntryCode(route)
).toString('base64')}`
function genWebpackBase64Code(code: string) {
return `data:text/javascript;base64,${Buffer.from(code).toString('base64')}`
}
function genNVueEntryCode(route: string) {
return `import App from '${normalizePath(
return `import '${genWebpackBase64Code(genNVueAppStyle())}'
import App from '${normalizePath(
path.resolve(process.env.UNI_INPUT_DIR, route)
)}.nvue?mpType=page'
${genNVueAppStyle()}
)}.nvue?mpType=page'
if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
var promise = this.constructor
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册