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

wip(app): nvue

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