家政小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

webpack.prod.config.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: 'td_icon.ico'
  59. },
  60. {
  61. from: 'src/styles/fonts',
  62. to: 'fonts'
  63. },
  64. {
  65. from: 'src/views/main-components/theme-switch/theme'
  66. },
  67. {
  68. from: 'src/views/my-components/text-editor/tinymce'
  69. }
  70. ], {
  71. ignore: [
  72. 'text-editor.vue'
  73. ]
  74. }),
  75. new HtmlWebpackPlugin({
  76. title: '家政后台',
  77. favicon: './td_icon.ico',
  78. filename: '../index.html',
  79. template: './src/template/index.ejs',
  80. inject: false
  81. })
  82. ]
  83. });