TencentCloudBase / cloudbase-js-sdk

Cloudbase 云开发 JavaScript SDK
https://www.cloudbase.net/
47 stars 13 forks source link

已经设置mode: 'production'了,打包后还是包含了很多无效的错误日志内容,增加包的体积 #14

Open kuole-o opened 3 years ago

kuole-o commented 3 years ago

麻烦帮忙看看,已经添加了mode: 'production'的配置,打包后,还是很大,有调试中的错误日志相关内容。

可以这里查看包:https://guole.fun/js/ispeak-bber.min.js


webpack.config.js配置信息如下,请帮忙看看

const path = require('path')
const webpack = require('webpack')
const CopyPlugin = require('copy-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const ROOT_PATH = path.resolve(__dirname)
const BUILD_PATH = path.resolve(ROOT_PATH, 'dist')
const packageinfo = require('./package.json').version
const TerserPlugin = require('terser-webpack-plugin')
var MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = {
  module: {
    mode: 'production',
    entry: {
      /* eslint-disable-next-line quote-props */
      'ispeak-bber-md': './src/js/main-md.js',
      'ispeak-bber': './src/js/main.js'
    },
    optimization: {
      minimize: true,
      minimizer: [new TerserPlugin()],
    },
    output: {
      path: BUILD_PATH,
      filename: '[name].min.js',
      library: 'ispeakBber',
      libraryTarget: 'umd'
    },
    rules: [
      { test: /\.vue$/, loader: 'vue-loader' },
      { test: /\.css$/, use: ['vue-style-loader', 'css-loader'] },
      { test: /\.svg$/, loader: 'svg-inline-loader' },
      {
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
            plugins: [
              '@babel/plugin-transform-modules-commonjs',
              '@babel/transform-runtime'
            ]
          }
        }
      },
      {
        test: /\.css$/,
        use: [
          process.env.NODE_ENV !== 'production'
            ? 'vue-style-loader'
            : MiniCssExtractPlugin.loader,
          'css-loader'
        ]
      }
    ]
  },
  target: ['web', 'es5'],
  plugins: [
    new webpack.BannerPlugin(`package version: ${packageinfo}`),
    new CopyPlugin({
      patterns: [{ from: 'demo/', to: './' }]
    }),
    new VueLoaderPlugin(),
    new TerserPlugin({
      parallel: 4,
      terserOptions: {
        ecma: 5,
        toplevel: true,
        ie8: true,
        safari10: true
      }
    }),
    new MiniCssExtractPlugin({
      filename: 'style.css'
    })
  ],
  devServer: {
    static: [
      {
        directory: BUILD_PATH,
        publicPath: '/dist/',
        serveIndex: true,
        watch: true
      }
    ],
    port: 9820,
    host: 'localhost',
    open: true,
    hot: true,
    compress: true
  },
  performance: {
    maxEntrypointSize: 524288,
    maxAssetSize: 524288
  }
}
kuole-o commented 3 years ago

如何强制禁用错误日志相关内容被打包呢