webpack.config.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. 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. },
  33. devtool: '#eval-source-map'
  34. }
  35. if (process.env.NODE_ENV === 'production') {
  36. module.exports.devtool = '#source-map'
  37. module.exports.plugins = (module.exports.plugins || []).concat([
  38. new webpack.DefinePlugin({
  39. 'process.env': {
  40. NODE_ENV: '"production"'
  41. }
  42. }),
  43. new webpack.optimize.UglifyJsPlugin({
  44. compress: {
  45. warnings: false
  46. }
  47. }),
  48. new webpack.optimize.OccurenceOrderPlugin()
  49. ])
  50. }