webpack.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @author oldj
  3. * @blog http://oldj.net
  4. */
  5. 'use strict'
  6. const path = require('path')
  7. const webpack = require('webpack')
  8. const moment = require('moment')
  9. const version = require('./app/version').version.join('.')
  10. module.exports = {
  11. entry: {
  12. app: './ui/index.jsx'
  13. //, vendor: ['react', 'antd']
  14. },
  15. devtool: 'source-map',
  16. output: {
  17. path: path.join(__dirname, 'app', 'ui')
  18. , filename: 'bundle.js'
  19. , sourceMapFilename: 'bundle.js.map'
  20. },
  21. resolve: {
  22. extensions: ['.js', '.jsx']
  23. },
  24. module: {
  25. rules: [
  26. {
  27. test: /\.jsx?$/,
  28. //exclude: [/node_modules/],
  29. use: ['babel-loader']
  30. }, {
  31. test: /\.less$/,
  32. use: ['style-loader', 'css-loader', 'less-loader']
  33. }, {
  34. test: /\.css$/,
  35. use: ['style-loader', 'css-loader']
  36. }, {
  37. test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
  38. use: 'url-loader?limit=30000&name=[name]-[hash].[ext]'
  39. }
  40. ]
  41. , noParse: [/\bAgent\b/]
  42. },
  43. plugins: [
  44. new webpack.DefinePlugin({
  45. 'process.env': {
  46. NODE_ENV: JSON.stringify('production')
  47. }
  48. })
  49. //, new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: 'common.js'})
  50. , new webpack.optimize.UglifyJsPlugin({
  51. sourceMap: true,
  52. compress: {
  53. warnings: false
  54. , drop_console: false
  55. }
  56. , output: {
  57. comments: false
  58. }
  59. })
  60. , new webpack.DllReferencePlugin({
  61. context: __dirname,
  62. manifest: require('./tmp/manifest.json')
  63. })
  64. , new webpack.IgnorePlugin(new RegExp('^(electron|fs|path)$'))
  65. , new webpack.BannerPlugin(`SwitchHosts! [file] v${version}, ${moment().format('YYYY-MM-DD HH:mm:ss')}`)
  66. ]
  67. }