webpack-merge-and-include-globally icon indicating copy to clipboard operation
webpack-merge-and-include-globally copied to clipboard

Exclude js files

Open vivekdaryani opened this issue 6 years ago • 6 comments

Not able to exclude js files by using regex

vivekdaryani avatar Nov 21 '19 10:11 vivekdaryani

@vivekdaryani what regex are you using and filename should be ignored?

markshapiro avatar Nov 21 '19 11:11 markshapiro

const MergeIntoSingleFilePlugin = require('webpack-merge-and-include-globally'); new MergeIntoSingleFilePlugin({ files: { 'responsive/3.0.11/js/aggregate.js': [path.resolve(src, 'responsive/3.0.11/js/backbone*.js'), '!'+path.resolve(src, 'responsive/3.0.11/js/backbone-alert*.js'), ]} })

vivekdaryani avatar Nov 21 '19 12:11 vivekdaryani

@vivekdaryani I believe a single entry responsive/3.0.11/js/backbone!(-alert)*.js' will solve this, just tested it locally (according to rules at https://www.npmjs.com/package/glob#glob-primer) but I should definitely add parameter of files to ignore

markshapiro avatar Nov 21 '19 16:11 markshapiro

Same to me. I'm not able to exclude files. I have the following array:

const allLegacyJSFiles = [
    path.resolve(__dirname, 'src/js/**/*.module.js'),
    path.resolve(__dirname, 'src/js/**/*!(.module)*.js'),
    '!'+path.resolve(__dirname, 'src/js/**/*.es6.js'),
];

and then

...
  plugins: [
        new MergeIntoSingleFilePlugin({
            files: {
                'legacy.js': allLegacyJSFiles,
            },
            transform: {
                'legacy.js': code => {
                    //let x = UglifyES.minify(code);
                    return code;
                },
            },
        }),
        new HtmlWebpackPlugin(),
    ],
...

and I see in the concatenation result all the .es6.js files that contain imports and export defaults keywords...

alessandro308 avatar May 08 '20 13:05 alessandro308

And even with

const allLegacyJSFiles = [
    path.resolve(__dirname, 'src/js/**/*.module.js'),
    path.resolve(__dirname, 'src/js/**/*!(.module|.es6)*.js'),
];

seems that .es6.js files are included 😕

alessandro308 avatar May 08 '20 14:05 alessandro308

@alessandro308 if you want to include all files except .es6.js you can do src/**/!(*.es6).js what were you trying to do with .module files? exclude them if something stands between .module and .js? using src/**/!(*.es6|*.module.*).js will exclude all files that end with module.*.js or es6.js you can use https://globster.xyz to test glob patterns

markshapiro avatar May 25 '20 14:05 markshapiro