Skip to content

Commit

Permalink
make sure copy is only run once
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Nov 15, 2022
1 parent a286997 commit de9b286
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions tsdx.config.js
Expand Up @@ -3,6 +3,9 @@ const replace = require('@rollup/plugin-replace');
const sass = require('rollup-plugin-scss');
const copy = require('rollup-plugin-copy');

// make sure copy is only added once
let copyAdded = false;

module.exports = {
rollup(config, options) {
config.plugins = [
Expand All @@ -19,15 +22,8 @@ module.exports = {
extensions: ['.css', '.scss', '.less'],
use: ['sass', ['less', { javascriptEnabled: true }]],
}),
copy({
targets: [
{
src: 'fonts/**/*',
dest: 'dist/fonts',
},
],
}),
];

config.plugins = config.plugins.map((plugin) =>
plugin.name === 'replace'
? replace({
Expand All @@ -36,6 +32,25 @@ module.exports = {
})
: plugin
);

config.plugins = [
...config.plugins,
!copyAdded
? copy({
targets: [
{
src: 'fonts/**/*',
dest: 'dist/fonts',
},
],
verbose: true,
copyOnce: true,
})
: false,
];

copyAdded = true;

return config;
},
};

0 comments on commit de9b286

Please sign in to comment.