webpack.config.babel.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import fs from 'fs';
  2. import webpack from 'webpack';
  3. let nodeModules = fs.readdirSync('./node_modules')
  4. .filter((module) => {
  5. return module !== '.bin';
  6. })
  7. .reduce((prev, module) => {
  8. return Object.assign(prev, {[module]: 'commonjs ' + module});
  9. }, {});
  10. export default {
  11. entry: ['./index.js'],
  12. output: {
  13. path: './dist',
  14. filename: 'index.js',
  15. library: 'electron-machine-id',
  16. libraryTarget: 'umd'
  17. },
  18. target: 'electron',
  19. module: {
  20. loaders: [
  21. {
  22. test: /\.js$/,
  23. exclude: /node_modules/,
  24. loader: 'babel',
  25. query: {
  26. cacheDirectory: true
  27. }
  28. },
  29. {
  30. test: /\.json$/,
  31. loader: 'json'
  32. }
  33. ]
  34. },
  35. plugins: [
  36. new webpack.IgnorePlugin(/node_modules/),
  37. new webpack.optimize.OccurrenceOrderPlugin(),
  38. new webpack.optimize.DedupePlugin(),
  39. new webpack.optimize.UglifyJsPlugin({
  40. compress: { warnings: false },
  41. output: { comments: false },
  42. })
  43. ],
  44. node: {
  45. //do not include polyfills...
  46. //http://webpack.github.io/docs/configuration.html#node
  47. console: false,
  48. process: false,
  49. child_process: false,
  50. global: false,
  51. buffer: false,
  52. crypto: false,
  53. __filename: false,
  54. __dirname: false
  55. },
  56. externals: nodeModules
  57. };