webpack.config.js 1.9 KB

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