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

wip(app): nvue

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