refactor: add more tructure to runtime dir

This commit is contained in:
Pooya Parsa 2020-11-11 15:03:55 +01:00
parent aff2372650
commit 8414e64eeb
6 changed files with 7 additions and 6 deletions

View File

@ -102,9 +102,9 @@ export const getRollupConfig = (config: SLSOptions) => {
options.plugins.push(alias({
entries: {
'~runtime': config.runtimeDir,
'~renderer': require.resolve(resolve(config.runtimeDir, renderer)),
'~renderer': require.resolve(resolve(config.runtimeDir, 'ssr', renderer)),
'~build': config.buildDir,
'~mock': require.resolve(resolve(config.runtimeDir, 'mock')),
'~mock': require.resolve(resolve(config.runtimeDir, 'utils/mock')),
...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {}),
...providedDeps.reduce((p, c) => ({ ...p, [c]: require.resolve(c) }), {})
}

View File

@ -15,6 +15,7 @@ if ('serviceWorker' in navigator) {
</script>`.replace(/\n| +/g, '')
return {
entry: '{{ runtimeDir }}/targets/service-worker',
targetDir: '{{ publicDir }}',
nuxtHooks: {
'vue-renderer:ssr:templateParams' (params) {

View File

@ -5,7 +5,7 @@ import { SLSOptions, SLSTarget } from '../config'
import { worker } from './worker'
export const cloudflare: SLSTarget = extendTarget(worker, {
entry: '{{ runtimeDir }}/cloudflare',
entry: '{{ runtimeDir }}/targets/cloudflare',
generateIgnore: [
'wrangler.toml'
],

View File

@ -4,7 +4,7 @@ import consola from 'consola'
import { SLSTarget } from '../config'
export const lambda: SLSTarget = {
entry: '{{ runtimeDir }}/lambda',
entry: '{{ runtimeDir }}/targets/lambda',
hooks: {
'done' ({ rollupConfig }) {
const entry = relative(process.cwd(), rollupConfig.output.file).replace(/\.js$/, '')

View File

@ -3,7 +3,7 @@ import consola from 'consola'
import { SLSTarget } from '../config'
export const node: SLSTarget = {
entry: '{{ runtimeDir }}/node',
entry: '{{ runtimeDir }}/targets/node',
hooks: {
'done' ({ rollupConfig }) {
const entry = relative(process.cwd(), rollupConfig.output.file).replace(/\.js$/, '')

View File

@ -12,7 +12,7 @@ const o=Date.now(),t=()=>Date.now()-o;process.hrtime=o=>{const e=Math.floor(.001
`
export const worker: SLSTarget = {
entry: '{{ runtimeDir }}/worker',
entry: null, // Abstract
node: false,
hooks: {
'rollup:before' ({ rollupConfig }) {