Skip to content

Commit

Permalink
feat: option for disabling esbuild (vitejs#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jul 4, 2020
1 parent 808e889 commit 54177b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/node/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export async function createBaseRollupPlugins(
rollupInputOptions = {},
transforms = [],
vueCustomBlockTransforms = {},
cssPreprocessOptions
cssPreprocessOptions,
enableEsbuild = true
} = options
const { nodeResolve } = require('@rollup/plugin-node-resolve')
const dynamicImport = require('rollup-plugin-dynamic-import-variables')
Expand All @@ -108,7 +109,9 @@ export async function createBaseRollupPlugins(
// vite:resolve
createBuildResolvePlugin(root, resolver),
// vite:esbuild
await createEsbuildPlugin(options.minify === 'esbuild', options.jsx),
enableEsbuild
? await createEsbuildPlugin(options.minify === 'esbuild', options.jsx)
: null,
// vue
require('rollup-plugin-vue')({
...options.rollupPluginVueOptions,
Expand Down
5 changes: 5 additions & 0 deletions src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ export interface SharedConfig {
* CSS preprocess options
*/
cssPreprocessOptions?: SFCStyleCompileOptions['preprocessOptions']
/**
* Enable esbuild
* @default true
*/
enableEsbuild?: boolean
}

export interface ServerConfig extends SharedConfig {
Expand Down
7 changes: 4 additions & 3 deletions src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export function createServer(config: ServerConfig): Server {
alias = {},
transforms = [],
vueCustomBlockTransforms = {},
optimizeDeps = {}
optimizeDeps = {},
enableEsbuild = true
} = config

const app = new Koa<State, Context>()
Expand Down Expand Up @@ -98,14 +99,14 @@ export function createServer(config: ServerConfig): Server {
: []),
vuePlugin,
cssPlugin,
esbuildPlugin,
enableEsbuild ? esbuildPlugin : null,
jsonPlugin,
assetPathPlugin,
webWorkerPlugin,
wasmPlugin,
serveStaticPlugin
]
resolvedPlugins.forEach((m) => m(context))
resolvedPlugins.forEach((m) => m && m(context))

const listen = server.listen.bind(server)
server.listen = (async (...args: any[]) => {
Expand Down

0 comments on commit 54177b3

Please sign in to comment.