andywer/webpack-blocks

Have setOutput accept an object

AlahmadiQ8 opened this issue · 1 comments

I have the following use case in webpack:

{
  output {
    filename: 'js/index.js',
    path: 'build',
}

currently setOutput only accepts a string. it would be nice to have it also accept an object to configure filename and path. Perhaps something like this:

function setOutput (output) {
  if (typeof output === 'string') {
    output = {
      filename: path.basename(output) || 'bundle.js',
      path: path.resolve(path.dirname(output) || './build')
    }
  } else if (typeof output === 'object') {
    output = {
      filename: output.filename || 'bundle.js',
      path: output.path || './build'
    }
  }

  return (context, util) => util.merge({ output })
}

Hey @AlahmadiQ8.

You can pass an output object if you want to. See the webpack blocks's README.

Feel free to re-open the issue if that doesn't work 😉