Code Monkey home page Code Monkey logo

Comments (2)

cora-li avatar cora-li commented on May 31, 2024 3

Hello everyone, I am also facing the same problem now.

Firstly, I strongly agree with alexlafroscia's view. Through my observation, I found that the buildStart and buildEnd hooks were executed too early, so that the chunks module that was later executed would empty the output folder. You can change the hook of the copy plugin to closeBundle to solve this problem. That's right, that's what I'm doing now. It works very well!

copy({
  hook: "closeBundle",
  targets: [
    { src: './dll/*', dest: 'dist/dll' },
  ]
}),

from rollup-plugin-copy.

alexlafroscia avatar alexlafroscia commented on May 31, 2024

I ran into this as well, but was able to work around it with the right hook value.

What I observed was that upon starting the Vite dev server, nothing was copied, but once I killed the process the files would be copied. Upon looking further into the way that this package works, this makes sense, as it defaults to writing the files on buildEnd. This seems to be called when the process is killed.

If I set the hook to "buildStart", however, the files are copied at the point that the server starts.

So, I have a configuration like this, which seems to be working as I would expect it to!

import * as path from "node:path";
import copy from "rollup-plugin-copy";

/** @type {import('vite').UserConfig} */
export default {
  plugins: [
    copy({
      targets: [
        {
          src: path.resolve(__dirname, "path/to/thing"),
          dest: path.resolve(__dirname, "public/path/to/thing"),
        },
      ],
      hook: "buildStart",
      copyOnce: true,
    }),
  ],
};

from rollup-plugin-copy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.