webpack.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var path = require('path')
  2. var webpack = require('webpack')
  3. module.exports = {
  4. entry: './lofig.js',
  5. output: {
  6. path: path.resolve(__dirname, './dist'),
  7. publicPath: '/dist',
  8. filename: 'lofig.min.js',
  9. },
  10. resolve: {
  11. alias: {
  12. modules: path.join(__dirname, 'node_modules')
  13. }
  14. },
  15. resolveLoader: {
  16. root: path.join(__dirname, 'node_modules'),
  17. },
  18. module: {
  19. loaders: [
  20. {
  21. test: /\.js$/,
  22. loader: 'babel',
  23. exclude: /node_modules/,
  24. query: {
  25. presets: ['es2015']
  26. }
  27. }
  28. ]
  29. },
  30. devServer: {
  31. historyApiFallback: true,
  32. noInfo: true
  33. },
  34. devtool: '#eval-source-map',
  35. plugins: [
  36. new webpack.ProvidePlugin({
  37. 'Promise': 'bluebird',
  38. 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
  39. }),
  40. ]
  41. }
  42. if (process.env.NODE_ENV === 'production') {
  43. module.exports.devtool = '#source-map'
  44. module.exports.plugins = (module.exports.plugins || []).concat([
  45. new webpack.DefinePlugin({
  46. 'process.env': {
  47. NODE_ENV: '"production"'
  48. }
  49. }),
  50. new webpack.optimize.UglifyJsPlugin({
  51. compress: {
  52. warnings: false
  53. }
  54. }),
  55. new webpack.optimize.OccurenceOrderPlugin()
  56. ])
  57. }