webpack.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var path = require('path')
  2. var webpack = require('webpack')
  3. module.exports = {
  4. entry: ['babel-polyfill', './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. module: {
  16. rules: [
  17. {
  18. test: /\.js$/,
  19. exclude: /node_modules/,
  20. use: {
  21. loader: 'babel-loader',
  22. options: {
  23. presets: ['@babel/preset-env']
  24. }
  25. }
  26. }
  27. ]
  28. },
  29. devServer: {
  30. historyApiFallback: true,
  31. noInfo: true,
  32. contentBase: './example'
  33. },
  34. devtool: '#eval-source-map'
  35. }
  36. if (process.env.NODE_ENV === 'production') {
  37. module.exports.devtool = '#source-map'
  38. module.exports.plugins = (module.exports.plugins || []).concat([
  39. new webpack.DefinePlugin({
  40. 'process.env': {
  41. NODE_ENV: '"production"'
  42. }
  43. }),
  44. new webpack.optimize.UglifyJsPlugin({
  45. compress: {
  46. warnings: false
  47. }
  48. }),
  49. new webpack.optimize.OccurenceOrderPlugin()
  50. ])
  51. }