Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete generated .js files (from .ts) in folder using webpack

I am trying to delete all .js files with in a folder which are generated from .ts files (from tsc) using clean-webpack-plugin

but it is not deleting specific files, it is deleting all files.

             new CleanWebpackPlugin(['app'],
                {
                    root: path.resolve('.'),
                    verbose: true,
                    dry: false,
                    exclude: ['**/*.ts','**/*.html']
                })

How can i solve this problem

  1. either do not generate .js from tsc just generate bundle.js from webpack

  2. delete only .js files and not .ts/.html/.css from a given folder

I also want to delete the build folder, seems like I would have to go back to gulp for this

like image 672
harishr Avatar asked Jun 21 '26 15:06

harishr


1 Answers

sorry my bad... i just had to change it like below to make it work

            new CleanWebpackPlugin(['app/**/*.js', 'build/**/*.*'],
                {
                    root: path.resolve('.'),
                    verbose: true,
                    dry: false
                })

so basically use reg-ex in paths itself.

like image 175
harishr Avatar answered Jun 24 '26 16:06

harishr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!