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.

89 lines
2.3 KiB

2 years ago
  1. 'use strict';
  2. const path = require('path');
  3. const defaultSettings = require('./settings.js');
  4. const devServer = require('./devServer'); //devServer相关配置
  5. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  6. /**自动加载关系**/
  7. const CreatedComponentsPlugin = require('./build/plugins/CreatedComponentsPlugin');
  8. function resolve(dir) {
  9. return path.join(__dirname, dir)
  10. }
  11. /***
  12. * @description 根据环境入口使用的插件
  13. * @type {CreatedComponentsPlugin[]}
  14. */
  15. let plugins = [];
  16. //console.log(process.env.npm_lifecycle_script.indexOf('gxdVue'), process.env);
  17. if(process.env.npm_lifecycle_script.indexOf('gxdVue') !== -1) {
  18. plugins.push(new UglifyJsPlugin({
  19. uglifyOptions: {
  20. compress: {
  21. warnings: false,
  22. drop_debugger: true, //去掉debugger
  23. drop_console: true, // 去掉console
  24. pure_funcs: ['console.log']// 移除console
  25. }
  26. },
  27. sourceMap: false,
  28. parallel: true
  29. }));
  30. }
  31. const name = defaultSettings.title || 'XD Vue Package'; // page title
  32. // All configuration item explanations can be find in https://cli.vuejs.org/config/
  33. module.exports = {
  34. /**
  35. * You will need to set publicPath if you plan to deploy your site under a sub path,
  36. * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
  37. * then publicPath should be set to "/bar/".
  38. * In most cases please use '/' !!!
  39. * Detail: https://cli.vuejs.org/config/#publicpath
  40. */
  41. publicPath: '/',
  42. outputDir: 'dist',
  43. assetsDir: 'static',
  44. /**是否关闭eslint语法检测**/
  45. lintOnSave: defaultSettings.isCloseEslint,
  46. productionSourceMap: false,
  47. devServer,
  48. css: {
  49. extract: false //设置不产生css样式模式
  50. },
  51. configureWebpack: {
  52. // provide the app's title in webpack's name field, so that
  53. // it can be accessed in index.html to inject the correct title.
  54. name: name,
  55. //关闭性能提示
  56. performance: {
  57. hints: false,
  58. //入口起点的最大体积
  59. maxEntrypointSize: 50000000,
  60. //生成文件的最大体积
  61. maxAssetSize: 30000000,
  62. //只给出 js 文件的性能提示
  63. assetFilter: function (assetFilename) {
  64. return assetFilename.endsWith('.js');
  65. }
  66. },
  67. resolve: {
  68. alias: {
  69. '@': resolve('src'),
  70. }
  71. },
  72. plugins
  73. },
  74. chainWebpack: (config) => {
  75. }
  76. };