harishr
harishr

Reputation: 18065

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

Upvotes: 3

Views: 1679

Answers (1)

harishr
harishr

Reputation: 18065

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.

Upvotes: 1

Related Questions