markshapiro / webpack-merge-and-include-globally

Merge multiple files (js, css..) and include by running them "as is". Supports minify by custom transform and wildcard paths.
MIT License
102 stars 27 forks source link

Exclude js files #22

Open vivekdaryani opened 5 years ago

vivekdaryani commented 5 years ago

Not able to exclude js files by using regex

markshapiro commented 5 years ago

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

vivekdaryani commented 5 years ago

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'), ]} })

markshapiro commented 5 years ago

@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

alessandro308 commented 4 years ago

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 commented 4 years ago

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 😕

markshapiro commented 4 years ago

@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