Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

module.exports = {
  module: {
    loaders: [
      {
        test: /.js$/,
        exclude: /node_modules/,
        loaders: ["babel-loader"],
      }
    ],
  },
  entry: "./src/scripts/*.js",
  output: {
    path: './src/build',
    filename: '[name].js'
  }
};

I am getting error like this,

ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./s
rc/scripts/* in E:Web projectReactJS
eact-tutorial
resolve file
  E:Web projectReactJS
eact-tutorialsrcscripts* doesn't exist
  E:Web projectReactJS
eact-tutorialsrcscripts*.webpack.js doesn't exist
  E:Web projectReactJS
eact-tutorialsrcscripts*.web.js doesn't exist
  E:Web projectReactJS
eact-tutorialsrcscripts*.js doesn't exist
  E:Web projectReactJS
eact-tutorialsrcscripts*.json doesn't exist
resolve directory
  E:Web projectReactJS
eact-tutorialsrcscripts* doesn't exist (directory d
efault file)
  E:Web projectReactJS
eact-tutorialsrcscripts*package.json doesn't exist
 (directory description file)

It is not searching for all the js file instead it is searching for *.js like that.Help me out what I missed

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
417 views
Welcome To Ask or Share your Answers For Others

1 Answer

Having one or few entry points should be enough for most of use cases, but if you really want to bundle up all files from directory you can use following:

As explained here: https://github.com/webpack/webpack/issues/370

var glob = require("glob");
// ...
entry: glob.sync("./src/scripts/*.js")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...