提交 a17ec656 编写于 作者: Q qiang

fix: nvue-native template

上级 d9d0300b
...@@ -13,7 +13,7 @@ const { ...@@ -13,7 +13,7 @@ const {
} = require('./manifest.js') } = require('./manifest.js')
const { const {
getMainEntry, getMainEntry,
getNVueMainEntry, getNVueMainEntry,
parseEntry, parseEntry,
parsePages, parsePages,
...@@ -28,36 +28,37 @@ const { ...@@ -28,36 +28,37 @@ const {
camelize, camelize,
hyphenate, hyphenate,
removeExt, removeExt,
normalizePath, normalizePath,
getComponentName, getComponentName,
convertStaticStyle convertStaticStyle,
getTemplatePath
} = require('./util') } = require('./util')
const { const {
getFlexDirection, getFlexDirection,
getPlatformProject, getPlatformProject,
isSupportSubPackages, isSupportSubPackages,
getPlatforms, getPlatforms,
getPlatformGlobal, getPlatformGlobal,
getPlatformScss, getPlatformScss,
getPlatformSass, getPlatformSass,
runByHBuilderX, runByHBuilderX,
isInHBuilderX, isInHBuilderX,
isInHBuilderXAlpha, isInHBuilderXAlpha,
getPlatformExts, getPlatformExts,
getPlatformTarget, getPlatformTarget,
getPlatformVue, getPlatformVue,
getPlatformCompiler, getPlatformCompiler,
getShadowCss, getShadowCss,
getPlatformCssVars, getPlatformCssVars,
getPlatformCssnano, getPlatformCssnano,
getShadowTemplate, getShadowTemplate,
jsPreprocessOptions, jsPreprocessOptions,
cssPreprocessOptions, cssPreprocessOptions,
htmlPreprocessOptions, htmlPreprocessOptions,
nvueJsPreprocessOptions, nvueJsPreprocessOptions,
nvueCssPreprocessOptions, nvueCssPreprocessOptions,
nvueHtmlPreprocessOptions, nvueHtmlPreprocessOptions,
devtoolModuleFilenameTemplate devtoolModuleFilenameTemplate
} = require('./platform') } = require('./platform')
...@@ -75,38 +76,39 @@ module.exports = { ...@@ -75,38 +76,39 @@ module.exports = {
parseEntry, parseEntry,
parsePages, parsePages,
getH5Options, getH5Options,
getMainEntry, getMainEntry,
getNVueMainEntry, getNVueMainEntry,
getPagesJson, getPagesJson,
getManifestJson, getManifestJson,
getNetworkTimeout, getNetworkTimeout,
runByHBuilderX, runByHBuilderX,
isInHBuilderX, isInHBuilderX,
isInHBuilderXAlpha, isInHBuilderXAlpha,
isSupportSubPackages, isSupportSubPackages,
getPlatforms, getPlatforms,
getFlexDirection, getFlexDirection,
getPlatformScss, getPlatformScss,
getPlatformSass, getPlatformSass,
getPlatformExts, getPlatformExts,
getPlatformTarget, getPlatformTarget,
getPlatformProject, getPlatformProject,
getPlatformVue, getPlatformVue,
getPlatformGlobal, getPlatformGlobal,
getShadowCss, getShadowCss,
getPlatformCssVars, getPlatformCssVars,
getPlatformCssnano, getPlatformCssnano,
getPlatformCompiler, getPlatformCompiler,
getShadowTemplate, getShadowTemplate,
parsePagesJson, parsePagesJson,
parseManifestJson, parseManifestJson,
getComponentName, getComponentName,
convertStaticStyle, convertStaticStyle,
getTemplatePath,
jsPreprocessOptions, jsPreprocessOptions,
cssPreprocessOptions, cssPreprocessOptions,
htmlPreprocessOptions, htmlPreprocessOptions,
nvueJsPreprocessOptions, nvueJsPreprocessOptions,
nvueCssPreprocessOptions, nvueCssPreprocessOptions,
nvueHtmlPreprocessOptions, nvueHtmlPreprocessOptions,
devtoolModuleFilenameTemplate devtoolModuleFilenameTemplate
} }
...@@ -115,5 +115,8 @@ module.exports = { ...@@ -115,5 +115,8 @@ module.exports = {
return str.replace('wx-', 'weixin-') return str.replace('wx-', 'weixin-')
} }
return str return str
}) }),
} getTemplatePath () {
return path.join(__dirname, '../template')
}
}
...@@ -8,7 +8,8 @@ const { ...@@ -8,7 +8,8 @@ const {
getNVueMainEntry, getNVueMainEntry,
nvueJsPreprocessOptions, nvueJsPreprocessOptions,
nvueHtmlPreprocessOptions, nvueHtmlPreprocessOptions,
devtoolModuleFilenameTemplate devtoolModuleFilenameTemplate,
getTemplatePath
} = require('@dcloudio/uni-cli-shared') } = require('@dcloudio/uni-cli-shared')
const WebpackAppPlusNVuePlugin = require('../packages/webpack-app-plus-nvue-plugin') const WebpackAppPlusNVuePlugin = require('../packages/webpack-app-plus-nvue-plugin')
...@@ -95,7 +96,7 @@ const rules = [{ ...@@ -95,7 +96,7 @@ const rules = [{
babelrc: false babelrc: false
} }
}, },
jsPreprocessorLoader jsPreprocessorLoader
], ],
exclude (modulePath) { exclude (modulePath) {
return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1 return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1
...@@ -161,38 +162,56 @@ rules.unshift({ ...@@ -161,38 +162,56 @@ rules.unshift({
if (process.env.UNI_USING_NATIVE) { if (process.env.UNI_USING_NATIVE) {
plugins.push(new WebpackUniMPPlugin()) plugins.push(new WebpackUniMPPlugin())
const array = [{
let nativeTemplatePath = path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
'weapp-tools/template/v8-native'
)
if (!fs.existsSync(nativeTemplatePath)) { // 兼容旧版本
nativeTemplatePath = path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
'weapp-tools/template/v8'
)
}
plugins.push(new CopyWebpackPlugin([{
from: path.resolve(process.env.UNI_INPUT_DIR, 'static'), from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
to: 'static' to: 'static'
}, { }]
from: nativeTemplatePath, if (process.env.UNI_USING_NVUE_COMPILER) {
to: process.env.UNI_OUTPUT_DIR array.push({
}, { from: path.resolve(getTemplatePath(), 'common'),
from: path.resolve( to: process.env.UNI_OUTPUT_DIR
process.env.UNI_HBUILDERX_PLUGINS, }, {
'weapp-tools/template/common' from: path.resolve(
), process.env.UNI_HBUILDERX_PLUGINS,
to: process.env.UNI_OUTPUT_DIR, 'weapp-tools/template/common'
ignore: [ ),
'*.js', to: process.env.UNI_OUTPUT_DIR,
'*.json', ignore: [
'__uniapppicker.html', '*.js',
'__uniappview.html' '*.json',
] '__uniapppicker.html',
}])) '__uniappview.html',
'__uniappmarker@3x.png',
'__uniappopenlocation.html',
'__uniapppicker.html'
]
})
} else {
let nativeTemplatePath = path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'weapp-tools/template/v8-native')
if (!fs.existsSync(nativeTemplatePath)) { // 兼容旧版本
nativeTemplatePath = path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
'weapp-tools/template/v8'
)
}
array.push({
from: nativeTemplatePath,
to: process.env.UNI_OUTPUT_DIR
}, {
from: path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
'weapp-tools/template/common'
),
to: process.env.UNI_OUTPUT_DIR,
ignore: [
'*.js',
'*.json',
'__uniapppicker.html',
'__uniappview.html'
]
})
}
plugins.push(new CopyWebpackPlugin(array))
} }
module.exports = function () { module.exports = function () {
...@@ -296,4 +315,4 @@ module.exports = function () { ...@@ -296,4 +315,4 @@ module.exports = function () {
zlib: false zlib: false
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册