How to add wildcard mapping in entry of webpack

前端 未结 5 1403
长发绾君心
长发绾君心 2020-12-04 16:50

I need to webpack all the js file in the script folder.I tried this

module.exports = {
  module: {
    loaders: [
      {
        test: /\\.js$/,
        ex         


        
5条回答
  •  Happy的楠姐
    2020-12-04 17:05

    Webpack is expecting a list of files for the entry configuration, not a glob pattern.

    You'll have to list the files manually, or automatically with this code snippet

    var fs = require('fs'),
        entries = fs.readdirSync('./src/scripts/').filter(function(file) {
            return file.match(/.*\.js$/);
        });
    

    and then pass it to webpack's config.

提交回复
热议问题