Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy occurs before generated bundle write when multi entry #62

Open
raphaelsoul opened this issue Jan 12, 2022 · 2 comments
Open

copy occurs before generated bundle write when multi entry #62

raphaelsoul opened this issue Jan 12, 2022 · 2 comments

Comments

@raphaelsoul
Copy link

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
Copy link
Author

seems copy plugin cannot recognize where the buildEnd hook came from

@kirill-gadzhiev
Copy link

@raphaelsoul Hi! Did you find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants