家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. const webpack = require('webpack');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  4. const CopyWebpackPlugin = require('copy-webpack-plugin');
  5. const cleanWebpackPlugin = require('clean-webpack-plugin');
  6. const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
  7. const merge = require('webpack-merge');
  8. const webpackBaseConfig = require('./webpack.base.config.js');
  9. const os = require('os');
  10. const fs = require('fs');
  11. const path = require('path');
  12. const package = require('../package.json');
  13. fs.open('./build/env.js', 'w', function(err, fd) {
  14. const buf = Buffer.from('export default "production";');
  15. fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {});
  16. });
  17. module.exports = merge(webpackBaseConfig, {
  18. output: {
  19. publicPath: '/dist/', // 修改 https://iv...admin 这部分为你的服务器域名
  20. filename: '[name].[hash].js',
  21. chunkFilename: '[name].[hash].chunk.js'
  22. },
  23. plugins: [
  24. new cleanWebpackPlugin(['dist/*'], {
  25. root: path.resolve(__dirname, '../')
  26. }),
  27. new ExtractTextPlugin({
  28. filename: '[name].[hash].css',
  29. allChunks: true
  30. }),
  31. new webpack.optimize.CommonsChunkPlugin({
  32. // name: 'vendors',
  33. // filename: 'vendors.[hash].js'
  34. name: ['vender-exten', 'vender-base'],
  35. minChunks: Infinity
  36. }),
  37. new webpack.DefinePlugin({
  38. 'process.env': {
  39. NODE_ENV: '"production"'
  40. }
  41. }),
  42. // new webpack.optimize.UglifyJsPlugin({
  43. // compress: {
  44. // warnings: false
  45. // }
  46. // }),
  47. new UglifyJsParallelPlugin({
  48. workers: os.cpus().length,
  49. mangle: true,
  50. compressor: {
  51. warnings: false,
  52. drop_console: true,
  53. drop_debugger: true
  54. }
  55. }),
  56. new CopyWebpackPlugin([
  57. {
  58. from: 'favicon.ico',
  59. to: '../'
  60. },
  61. {
  62. from: 'src/styles/fonts',
  63. to: 'fonts'
  64. },
  65. {
  66. from: 'src/views/main-components/theme-switch/theme'
  67. },
  68. {
  69. from: 'src/views/my-components/text-editor/tinymce'
  70. }
  71. ], {
  72. ignore: [
  73. 'text-editor.vue'
  74. ]
  75. }),
  76. new HtmlWebpackPlugin({
  77. title: '家政后台',
  78. favicon: './favicon.ico',
  79. filename: '../index.html',
  80. template: './src/template/index.ejs',
  81. inject: false
  82. })
  83. ]
  84. });