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

Configure bundled files -- disable dev builds #508

Open
pedrouid opened this issue Feb 12, 2020 · 2 comments
Open

Configure bundled files -- disable dev builds #508

pedrouid opened this issue Feb 12, 2020 · 2 comments
Labels
kind: feature New feature or request solution: workaround available There is a workaround available for this issue

Comments

@pedrouid
Copy link

pedrouid commented Feb 12, 2020

I want to configure the name of the output files and which files are bundled.

By default, the JS that are output'd are an index file, cjs and esm files with both production and development versions and respective maps. But I want to build a single umd file named index.js.

So I added the following flags to the build command:

tsdx build --format umd --name index

However this while output no index file and two umd files both production and development versions and respective maps.

So I just added postbuild script to copy the contents of the production files and delete the other files.

# rename dist files
cp ./dist/index.umd.production.min.js ./dist/index.js 
cp ./dist/index.umd.production.min.js.map ./dist/index.js.map

# delete duplicates
rm -rf ./dist/index.umd.*

Ideally all I want to output is a single production minified file called index.js and respective map index.js.map.

How can I achieve this by configuring the tsdx.config.js??

@agilgur5
Copy link
Collaborator

agilgur5 commented Mar 7, 2020

You can do:

module.exports = {
  rollup (config, opts) {
    if (opts.environment === 'development') {
       // redirect dev build to nowhere
       config.output.file = '/dev/null'
    } else {
      // rename prod build to index.js
      config.output.file = './dist/index.js'
    }
  }
}

And I think it should work (not 100% sure about sourcemaps, but think they should also be renamed fine), but as you'll notice it's kind of hacky with the /dev/null. There's no way to cancel a dev/prod build right now. So your current method is probably more optimal (and less subject to breakage)

@agilgur5 agilgur5 changed the title Configure bundled files Configure bundled files -- disable dev builds Mar 10, 2020
@agilgur5 agilgur5 added the kind: feature New feature or request label Mar 20, 2020
@agilgur5 agilgur5 added the solution: workaround available There is a workaround available for this issue label Apr 22, 2020
@EnKrypt
Copy link

EnKrypt commented Apr 24, 2021

This would really be good to have. I don't want to include development builds into the published tarball.

Right now I'm removing the development files and modifying index.js manually after publishing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New feature or request solution: workaround available There is a workaround available for this issue
Projects
None yet
Development

No branches or pull requests

3 participants