rollup-plugin-copy icon indicating copy to clipboard operation
rollup-plugin-copy copied to clipboard

copy occurs before generated bundle write when multi entry

Open raphaelsoul opened this issue 3 years ago • 2 comments

export default [
  {
    input: 'src/main.ts',
    output: {
      sourcemap: false,
      file: `dist/music-v${version}.min.js`,
      format: 'umd',
      plugins: [
        terser(),
      ],
    },
    plugins: [
        ...makeBasicPlugins({}),
        license({
          banner: {
            content: {
              file: 'LICENSE.md',
              encoding: 'utf-8',
            },
          },
        }),
        copy({
          verbose: true,
          hook: '',
          targets: [
            {
              // eslint-disable-next-line no-undef
              src: path.join(__dirname, `dist/music-v${version}.min.js`),
              // eslint-disable-next-line no-undef
              dest: path.join(__dirname, '../backend/public/js')
            }
          ]
        })
    ],
  },
  {
    input: 'src/main.ts',
    output: {
      sourcemap: true,
      file: `dist/music.debug.js`,
      format: 'umd',
    },
    plugins: [
      ...makeBasicPlugins({ sourceMap: true, NODE_ENV: 'debug' }),
      copy({
        verbose: true,
        targets: [
          {
            // eslint-disable-next-line no-undef
            src: path.join(__dirname, 'dist/music.debug.js'),
            // eslint-disable-next-line no-undef
            dest: path.join(__dirname, '../backend/public/js')
          },
          {
            // eslint-disable-next-line no-undef
            src: path.join(__dirname, 'dist/music.debug.js.map'),
            // eslint-disable-next-line no-undef
            dest: path.join(__dirname, '../backend/public/js')
          },
        ]
      })
    ],
  },
];

First clean both copy source and target directory, Then run rollup command, got

$ cross-env NODE_ENV=production rollup -c rollup.config.js

src/main.ts → dist/music-v0.0.1.min.js...
created dist/music-v0.0.1.min.js in 6.9s

src/main.ts → dist/music.debug.js...
no items to copy
created dist/music.debug.js in 4.4s
✨  Done in 12.37s.
✨  Done in 12.68s.

result is not stable

raphaelsoul avatar Jan 12 '22 10:01 raphaelsoul

seems copy plugin cannot recognize where the buildEnd hook came from

raphaelsoul avatar Jan 12 '22 10:01 raphaelsoul

@raphaelsoul Hi! Did you find a solution?

kirill-gadzhiev avatar Jan 09 '23 07:01 kirill-gadzhiev