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

wip(app): nvue

上级 5df88a23
......@@ -18,16 +18,17 @@ export { initNVueNodeTransforms } from './plugin'
export function initNVuePlugins() {
const renderer = process.env.UNI_RENDERER
const app = process.env.UNI_COMPILER_NVUE === 'app'
return [
uniAppCssPlugin(),
uniEasycomPlugin({ exclude: UNI_EASYCOM_EXCLUDE }),
uniHBuilderXConsolePlugin(),
uniMainJsPlugin({ renderer }),
...(process.env.UNI_RENDERER === 'native' ? [uniManifestJsonPlugin()] : []),
uniPagesJsonPlugin({ renderer }),
uniMainJsPlugin({ app }),
...(app ? [uniManifestJsonPlugin()] : []),
uniPagesJsonPlugin({ app }),
uniViteInjectPlugin('uni:app-inject', initAppProvide()),
uniStatsPlugin(),
uniAppNVuePlugin(),
uniEsbuildPlugin({ renderer }),
uniEsbuildPlugin({ renderer, app }),
]
}
......@@ -18,8 +18,10 @@ const debugEsbuild = debug('uni:app-nvue-esbuild')
export function uniEsbuildPlugin({
renderer,
app,
}: {
renderer?: 'native'
app: boolean
}): Plugin {
let buildOptions: BuildOptions
const outputDir = process.env.UNI_OUTPUT_DIR
......@@ -50,7 +52,7 @@ export function uniEsbuildPlugin({
entryPoints.push(name)
}
})
if (renderer === 'native') {
if (app) {
debugEsbuild('start', APP_SERVICE_FILENAME)
await buildNVueAppService(buildOptions).then((code) => {
return fs.outputFile(
......
import { defineUniMainJsPlugin, PAGES_JSON_JS } from '@dcloudio/uni-cli-shared'
import { APP_CSS_JS } from './appCss'
export function uniMainJsPlugin({ renderer }: { renderer?: 'native' }) {
export function uniMainJsPlugin({ app }: { app: boolean }) {
return defineUniMainJsPlugin((opts) => {
return {
name: 'uni:app-nvue-main-js',
enforce: 'pre',
transform(code, id) {
if (opts.filter(id)) {
if (renderer === 'native') {
if (app) {
code = code.includes('createSSRApp')
? createApp(code)
: createLegacyApp(code)
return {
code:
`import './${PAGES_JSON_JS}';import('${APP_CSS_JS}').then(()=>{});` +
code,
code,
map: { mappings: '' },
}
}
......
......@@ -11,11 +11,7 @@ import {
MANIFEST_JSON_JS,
} from '@dcloudio/uni-cli-shared'
export function uniPagesJsonPlugin({
renderer,
}: {
renderer?: 'native'
}): Plugin {
export function uniPagesJsonPlugin({ app }: { app: boolean }): Plugin {
return defineUniPagesJsonPlugin((opts) => {
return {
name: 'uni:app-nvue-pages-json',
......@@ -38,7 +34,7 @@ export function uniPagesJsonPlugin({
)
}
})
if (renderer === 'native') {
if (app) {
this.emitFile({
fileName: `app-config-service.js`,
type: 'asset',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册