GithubHelp home page GithubHelp logo

Copy static files about tsup HOT 6 OPEN

egoist avatar egoist commented on August 24, 2024 16
Copy static files

from tsup.

Comments (6)

NuroDev avatar NuroDev commented on August 24, 2024 25

Would it be possible / worth updating the publicDir property to additionally accept an array or record like entry so we can manually map out multiple public / static asset (directories) that need to be copied.

Something like this:

import { defineConfig } from 'tsup';

export default defineConfig({
	publicDir: [
		'./src/assets/',
		'./src/static/'
	]
});

// OR

export default defineConfig({
	publicDir: {
		'./src/assets/': './dist/assets/',
		'./src/static/': ({ output }) => `${output}/static/`
	}
});

In theory I thought a work around for this would be to return an array of configs & just have multiple publicDir's that way but with no entry point it does not work.

While --onSuccess "cp -a public/. dist" works, there is a few things that aren't ideal about it:

  • Desync with your output directory name (Though this could be fixed with a template string)
  • CLI exec is not ideal & would be better if it was all done pragmatically. In the same way rm -rf ./dist/ works, but not on Windows systems so people often use rimraf to add platform agnostic support.

from tsup.

egoist avatar egoist commented on August 24, 2024 7

This can be achieved with the onSuccess option, like --onSuccess "cp -a public/. dist" which copies everything inside public folder to your dist folder.

from tsup.

domdomegg avatar domdomegg commented on August 24, 2024 1

The --publicDir argument will copy everything in the public folder into the dist folder.

https://tsup.egoist.dev/#copy-files-to-output-directory

from tsup.

niaxi avatar niaxi commented on August 24, 2024

How are folks dealing with this currently? Wrapper build script? Example?

from tsup.

zheeeng avatar zheeeng commented on August 24, 2024

Any progress on this feature?

from tsup.

eric-burel avatar eric-burel commented on August 24, 2024

Something I've noticed, cp public/ dist/ && tsup will somehow delete the files copied in dist/public/. However I found no mention of "public" in the doc. The solution is to do the copy after Tsup has built but that's kinda weird.

from tsup.

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.