webpack.build.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @Author: HuaChao Chen <CHC>
  3. * @Date: 2017-05-04T23:21:48+08:00
  4. * @Email: chenhuachaoxyz@gmail.com
  5. * @Filename: webpack.dev.js
  6. * @Last modified by: CHC
  7. * @Last modified time: 2017-06-18T23:32:44+08:00
  8. * @License: MIT
  9. * @Copyright: 2017
  10. */
  11. var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  12. var base = require('./webpack.base.js')
  13. var merge = require('merges-utils')
  14. var path = require('path');
  15. var webpack = require('webpack');
  16. var config = {
  17. entry: {
  18. index: path.resolve(__dirname, '../src/index.js')
  19. },
  20. output: {
  21. path: path.resolve(__dirname, '../dist'),
  22. // publicPath: '/dist/',
  23. filename: 'mavon-editor.js',
  24. chunkFilename: 'js/[name].js',
  25. library: 'MavonEditor',
  26. libraryTarget: 'umd',
  27. umdNamedDefine: true
  28. },
  29. resolve: {
  30. alias: {
  31. 'muse-components': 'muse-ui/src'
  32. },
  33. extensions: ['.js', '.vue', '.less']
  34. },
  35. externals: {
  36. vue: {
  37. root: 'Vue',
  38. commonjs: 'vue',
  39. commonjs2: 'vue',
  40. amd: 'vue'
  41. }
  42. },
  43. plugins: [
  44. new BundleAnalyzerPlugin({
  45. // Can be `server`, `static` or `disabled`.
  46. // In `server` mode analyzer will start HTTP server to show bundle report.
  47. // In `static` mode single HTML file with bundle report will be generated.
  48. // In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`.
  49. analyzerMode: 'server',
  50. // Host that will be used in `server` mode to start HTTP server.
  51. analyzerHost: '127.0.0.1',
  52. // Port that will be used in `server` mode to start HTTP server.
  53. analyzerPort: 8888,
  54. // Path to bundle report file that will be generated in `static` mode.
  55. // Relative to bundles output directory.
  56. reportFilename: 'report.html',
  57. // Module sizes to show in report by default.
  58. // Should be one of `stat`, `parsed` or `gzip`.
  59. // See "Definitions" section for more information.
  60. defaultSizes: 'parsed',
  61. // Automatically open report in default browser
  62. openAnalyzer: true,
  63. // If `true`, Webpack Stats JSON file will be generated in bundles output directory
  64. generateStatsFile: false,
  65. // Name of Webpack Stats JSON file that will be generated if `generateStatsFile` is `true`.
  66. // Relative to bundles output directory.
  67. statsFilename: 'stats.json',
  68. // Options for `stats.toJson()` method.
  69. // For example you can exclude sources of your modules from stats file with `source: false` option.
  70. // See more options here: https://github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21
  71. statsOptions: null,
  72. // Log level. Can be 'info', 'warn', 'error' or 'silent'.
  73. logLevel: 'info'
  74. })
  75. ]
  76. }
  77. var res = merge([base, config])
  78. res.plugins = res.plugins.concat([
  79. new webpack.optimize.UglifyJsPlugin({
  80. compress: {
  81. warnings: false
  82. },
  83. comments: false
  84. })
  85. ])
  86. module.exports = res