Sunday, 2 April 2017

output.filename is required webpack

I tried to do the webpack exports in the following way. I tried to convert the async to sync ( regarding fs.readdir) to get the total files within directory.

const webpack = require('webpack');
const async = require('async'); 
const path = require('path');
const fs = require('fs');
var fileList = [];

var promiso = new Promise(function(res, rej) {
   fs.readdir(__dirname + "/imports/components", function(err, files)   {
      files.forEach(function(file) {
          console.log("file", file);
          fileList.push(file);
      });

      let config = {
          entry: {
             'myPages': fileList[0]
          },
          module: {
              loaders: [
                  // Javascript: js, jsx
                 {
                    test: /\.jsx?$/,
                    loader: 'babel-loader',
                    query: {
                        presets: ['es2015', 'react']
                    }
                }
            ]
        },
        output: {
            path: path.resolve(__dirname, 'dist'),
            filename: './bundler.js'
        },
    }
    res(config)
  })
});

promiso.then(function(mess) {
  console.log("-------------------------mess", mess);
  module.exports = mess;
});

I am getting following error

'output.filename' is required, either in config file or as --output-filename



via Sai Ram

No comments:

Post a Comment