railsware / bozon

🛠 Command line tool for building, testing and publishing modern Electron applications
MIT License
758 stars 52 forks source link

webpack config to add json-loader #42

Closed hdn8 closed 7 years ago

hdn8 commented 7 years ago

I have a dependency that requires loading a json, but to work with webpack I need to include json-loader, else throws:

... /app/node_modules/mime/types.json Unexpected token (1:27)
You may need an appropriate loader to handle this file type.

Can be reproduced installing and instantiating the node-mime module.

Adding the loader manually to bozon/lib/building/tasks.js it solves the problem:

bozon.task('scripts:renderer', function () {
  var webpack = bozon.requireLocal('webpack-stream')
  return bozon.src('javascripts/renderer/application.*').pipe(webpack({
    target: 'electron',
    output: {
      filename: 'application.js'
    },
    module: {
        loaders: [
            { test: /\.json$/, loader: "json-loader" }
        ]
    }
  })).pipe(bozon.dest('javascripts/renderer'))
})

Can this be done somehow in the bozon config files? I'm not so clear on how to do webpack config with the bozon config files setup.

alchaplinsky commented 7 years ago

Added support for webpack.config.js in v0.7.5