webpack上的通配符入口点usng glob出错 [英] wildcard entry point usng glob on webpack got error

查看:30
本文介绍了webpack上的通配符入口点usng glob出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试对我所有的 js 文件进行通配符匹配,但出现此错误

Trying to do wildcard matching for all my js file but I got this error

var elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!");
                                               ^

TypeError: request.replace is not a function
    at C:\Users\Superant-Laptop\Projects\seeties-webapp\node_modules\webpack\lib\NormalModuleFactory.js:72:27

这就是我配置 webpack 文件的方式.

This is how I configure my webpack file.

function toObject(paths) {
  console.log(paths)
  var ret = {};

  paths.forEach(function(path) {
    ret[path.split('/').slice(-1)[0]] = path;
  });

  return ret;
}

module.exports = {
  entry: [
    'webpack/hot/dev-server',
    'webpack-hot-middleware/client', 
    toObject(glob.sync(path.join(__dirname, 'resources/assets/bundle/entries/*js')))
  ],
  output: {
    path: path.join(__dirname, 'public'),
    publicPath: '/',
    filename: 'app.js'
  }
}

我上面的 webpack.config.js 有什么问题?对我来说看起来没问题.

what's wrong with my webpack.config.js above? It looks ok for me.

推荐答案

entries/*js -> entries/*.js

怎么样?

这篇关于webpack上的通配符入口点usng glob出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆