Skip to content

copy occurs before generated bundle write when multi entry #62

@raphaelsoul

Description

@raphaelsoul
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions