unbuild icon indicating copy to clipboard operation
unbuild copied to clipboard

minify support

Open danielroe opened this issue 2 years ago • 3 comments

Maybe we can support min flag for unbuild and unify tooling?

see https://github.com/nuxt-community/color-mode-module/pull/118#discussion_r796728630

danielroe avatar Feb 01 '22 20:02 danielroe

Is there any workaround?

seanghay avatar Apr 11 '22 04:04 seanghay

@seanghay I found this config seemed to work:

  rollup: {
    esbuild: {
      minify: true,
    },
  },

fwouts avatar Jul 06 '22 00:07 fwouts

@pi0 I also have this problem, and my unbuild config this:

import { defineBuildConfig } from "unbuild";

export default defineBuildConfig({
  entries: ["./index"],
  declaration: true,
  clean: true,
  failOnWarn: false,
  rollup: {
    emitCJS: true,
    esbuild: {
      minify: true
    }
  }
});

But after pnpm build , I get this error:

Error building E:/project/changan-incall/packages/microApp: Error: Transform failed with 1 error:
<stdin>:1:10: ERROR: Expected ";" but found "EnterMicroAppParams"
Error: Transform failed with 1 error:
<stdin>:1:10: ERROR: Expected ";" but found "EnterMicroAppParams"
    at failureErrorWithLog (E:\project\changan-incall\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1624:15)
    at E:\project\changan-incall\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1413:29
    at E:\project\changan-incall\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:678:9
    at handleIncomingPacket (E:\project\changan-incall\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:775:9)
    at Socket.readFromStdout (E:\project\changan-incall\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:644:7)
    at Socket.emit (node:events:526:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [],
      pluginName: '',
      text: 'Expected ";" but found "EnterMicroAppParams"'
    }
  ],
  warnings: [],
  code: 'PLUGIN_ERROR',
  plugin: 'esbuild',
  hook: 'renderChunk'
}

How Can I resolve this ?

xieyezi avatar Sep 06 '22 01:09 xieyezi

But after pnpm build , I get this error:

I have encountered this error as well. It may be caused by esbuild trying to minify a ts/d.ts file.

SukkaW avatar Apr 13 '23 05:04 SukkaW