提交 af39305e 编写于 作者: Q qiang

Merge branch 'dev' of github.com:dcloudio/uni-app into dev

......@@ -49,7 +49,6 @@ const {
getPlatformExts,
getPlatformTarget,
getPlatformVue,
getPlatformCompiler,
getShadowCss,
getPlatformCssVars,
getPlatformCssnano,
......@@ -99,7 +98,6 @@ module.exports = {
getShadowCss,
getPlatformCssVars,
getPlatformCssnano,
getPlatformCompiler,
getShadowTemplate,
parsePagesJson,
parseManifestJson,
......
......@@ -11,12 +11,6 @@ const {
} = require('./scss')
const uniRuntime = '@dcloudio/vue-cli-plugin-uni/packages/mp-vue'
const mpvueRuntime = '@dcloudio/vue-cli-plugin-uni/packages/mpvue'
const megaloRuntime = '@dcloudio/vue-cli-plugin-uni/packages/megalo'
const uniCompiler = '@dcloudio/uni-template-compiler'
const mpvueCompiler = '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler'
const megaloCompiler = '@megalo/template-compiler'
function getShadowCss () {
let tagName = 'page'
......@@ -94,7 +88,6 @@ const PLATFORMS = {
exts: false,
vue: '@dcloudio/vue-cli-plugin-uni/packages/h5-vue',
compiler: false,
megalo: false,
filterTag: 'wxs',
subPackages: false,
cssVars: {
......@@ -149,9 +142,6 @@ const PLATFORMS = {
template: '.wxml',
filter: '.wxs'
},
vue: mpvueRuntime,
compiler: mpvueCompiler,
megalo: false,
filterTag: 'wxs',
subPackages: false,
cssVars: {},
......@@ -203,9 +193,6 @@ const PLATFORMS = {
template: '.qml',
filter: '.wxs'
},
vue: mpvueRuntime,
compiler: mpvueCompiler,
megalo: false,
filterTag: 'wxs',
subPackages: true,
cssVars: {
......@@ -230,9 +217,6 @@ const PLATFORMS = {
template: '.wxml',
filter: '.wxs'
},
vue: mpvueRuntime,
compiler: mpvueCompiler,
megalo: false,
filterTag: 'wxs',
subPackages: true,
cssVars: {
......@@ -267,9 +251,6 @@ const PLATFORMS = {
template: '.swan',
filter: '.filter.js'
},
vue: megaloRuntime,
compiler: megaloCompiler,
megalo: 'swan',
filterTag: 'filter',
subPackages: true,
cssVars: {
......@@ -294,9 +275,6 @@ const PLATFORMS = {
template: '.axml',
filter: '.sjs'
},
vue: megaloRuntime,
compiler: megaloCompiler,
megalo: 'alipay',
filterTag: 'sjs',
subPackages: true,
cssVars: {
......@@ -319,9 +297,6 @@ const PLATFORMS = {
style: '.ttss',
template: '.ttml'
},
vue: megaloRuntime,
compiler: megaloCompiler,
megalo: 'tt',
subPackages: false,
cssVars: {
'--status-bar-height': '25px',
......@@ -580,16 +555,6 @@ module.exports = {
}
return platform.vue
},
getPlatformCompiler () {
if (
process.env.UNI_USING_COMPONENTS ||
process.env.UNI_PLATFORM === 'h5' ||
process.env.UNI_PLATFORM === 'quickapp'
) {
return require(uniCompiler)
}
return require(platform.compiler)
},
getPlatformCssVars () {
return platform.cssVars
},
......
const defaultOptions = {
compiler: require('@dcloudio/uni-template-compiler'),
hotReload: false,
cacheDirectory: false,
cacheIdentifier: false
}
const defaultCompilerOptions = {
preserveWhitespace: false
}
module.exports = {
test: [/\.vue$/, /\.nvue$/],
loader: require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vue-loader'),
options (options = {}, compilerOptions = {}) {
return Object.assign({},
defaultOptions,
options, {
compilerOptions: Object.assign({}, defaultCompilerOptions, compilerOptions)
})
}
}
const vueLoader = require('@dcloudio/uni-cli-shared/lib/vue-loader')
module.exports = config => {
config.module
.rule('vue')
.test([/\.vue$/, /\.nvue$/])
.test(vueLoader.test)
.use('vue-loader')
.loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vue-loader'))
.tap(options => Object.assign(options, {
compiler: require('@dcloudio/uni-template-compiler'),
compilerOptions: {
quickapp: true,
preserveWhitespace: false
},
hotReload: false,
cacheDirectory: false,
cacheIdentifier: false
}))
.loader(vueLoader.loader)
.tap(options => Object.assign(options, vueLoader.options({}, {
quickapp: true,
})))
config.module
.rule('vue')
......
......@@ -7,6 +7,8 @@ const {
getPlatformCompiler
} = require('@dcloudio/uni-cli-shared')
const vueLoader = require('@dcloudio/uni-cli-shared/lib/vue-loader')
const {
getGlobalUsingComponentsCode
} = require('@dcloudio/uni-cli-shared/lib/pages')
......@@ -14,7 +16,6 @@ const {
const WebpackUniAppPlugin = require('../../packages/webpack-uni-app-loader/plugin/index')
const {
isUnaryTag,
getPartialIdentifier
} = require('../util')
......@@ -245,7 +246,6 @@ const v3 = {
}
const compilerOptions = {
isUnaryTag,
preserveWhitespace: false,
service: isAppService,
view: isAppView
......@@ -254,23 +254,14 @@ const v3 = {
// disable vue cache-loader
webpackConfig.module
.rule('vue')
.test([/\.vue$/, /\.nvue$/])
.test(vueLoader.test)
.use('vue-loader') // service 层移除 style 节点,view 层返回固定 script
.loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vue-loader'))
.tap(options => Object.assign(options, {
.loader(vueLoader.loader)
.tap(options => Object.assign(options, vueLoader.options({
isAppService,
isAppView,
compiler: getPlatformCompiler(),
compilerOptions
}, cacheConfig))
isAppView
}, compilerOptions), cacheConfig))
.end()
// .use('uniapp-custom-block-loader')
// .loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader'))
// .options({
// isAppService,
// isAppView,
// compiler: getPlatformCompiler()
// })
// 是否启用 cache
if (process.env.UNI_USING_CACHE) {
......
......@@ -180,7 +180,14 @@ global.onAppShow = function(){};
webpackConfig.plugins.delete('preload-index')
}
modifyVueLoader(webpackConfig, require('./compiler-options'), api)
modifyVueLoader(webpackConfig, {
isH5: true,
hotReload: true,
transformAssetUrls: {
'v-uni-image': ['src'],
'v-uni-cover-image': ['src']
}
}, require('./compiler-options'), api)
if (process.env.NODE_ENV === 'production') {
require('./cssnano-options')(webpackConfig)
......
......@@ -17,11 +17,7 @@ const {
} = require('./cache-loader')
function createUniMPPlugin () {
if (process.env.UNI_USING_COMPONENTS) {
const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new')
return new WebpackUniMPPlugin()
}
const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin')
const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new')
return new WebpackUniMPPlugin()
}
......@@ -181,7 +177,7 @@ module.exports = {
const compilerOptions = process.env.UNI_USING_COMPONENTS ? {} : require('./mp-compiler-options')
modifyVueLoader(webpackConfig, compilerOptions, api)
modifyVueLoader(webpackConfig, {}, compilerOptions, api)
const styleExt = getPlatformExts().style
......
const {
getPlatformCompiler
} = require('@dcloudio/uni-cli-shared')
const vueLoader = require('@dcloudio/uni-cli-shared/lib/vue-loader')
const {
isUnaryTag,
getPartialIdentifier
} = require('./util')
module.exports = function modifyVueLoader (webpackConfig, compilerOptions, api) {
module.exports = function modifyVueLoader (webpackConfig, loaderOptions, compilerOptions, api) {
// vue-loader options
const cacheConfig = {
......@@ -24,23 +21,11 @@ module.exports = function modifyVueLoader (webpackConfig, compilerOptions, api)
webpackConfig.module
.rule('vue')
.test([/\.vue$/, /\.nvue$/])
.test(vueLoader.test)
.use('vue-loader')
.loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vue-loader'))
.tap(options => Object.assign(options, {
isH5: process.env.UNI_PLATFORM === 'h5',
compiler: getPlatformCompiler(),
compilerOptions: Object.assign({
isUnaryTag,
preserveWhitespace: false
}, compilerOptions)
}, cacheConfig))
.loader(vueLoader.loader)
.tap(options => Object.assign(options, vueLoader.options(loaderOptions, compilerOptions), cacheConfig))
.end()
// .use('uniapp-custom-block-loader')
// .loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader'))
// .options({
// compiler: getPlatformCompiler()
// })
// h5 框架需要使用 scoped 样式,其他平台编译时识别是否 nvue 文件且注入 flex 相关样式
if (process.env.UNI_PLATFORM === 'h5') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册