1.0.2 • Published 2 months ago

emnj-sentry-webpack-plugin v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

emnj-sentry-webpack-plugin

  1. 这个项目主要目的是简化基于webpack构建的项目,上传sourcemaps到平台的配置。
  2. 由于官方的插件@sentry/webpack-plugin更新非常快,最新版已经不适配当前私有化部署版本了。所以通过当前项目固定官方插件版本。

文档地址

使用文档

安装

# npm
npm i emnj-sentry-webpack-plugin
# yarn
yarn add emnj-sentry-webpack-plugin
# pnpm
pnpm install emnj-sentry-webpack-plugin

如何使用

EmnjSentryWebpackPlugin插件的所有配置参数选项和官方的1.21.0版本配置选项相同,参考地址:1.21.0版本配置选项

webpack配置

const EmnjSentryWebpackPlugin = require('emnj-sentry-webpack-plugin');

const isBuildProd = process.env.BUILD_ENV == 'production';

const plugins = []
if (isBuildProd) {
    plugins.push(new EmnjSentryWebpackPlugin({
            // 建议每次发布一个生产版本,release版本变更一下  
            release: '1.0.0',
            org: "your org",
            project: "your project",
            // 重要:资源上传的url,不配置这是sentry官网的域名。
            url: 'https://*******.com/',
            // 重要:认证的token
            authToken: '**********************',
            // 只需要是打包后资源目录下的js和map文件
            include: ['./dist/**/*.js', './dist/**/*.map'],
            // 根目录下可以配置忽略上传的文件规则
            ignoreFile: '.sentrycliignore',
            ignore: ['node_modules', 'webpack.config.js'],
            configFile: 'sentry.properties',
            // 这个比较重要,未配置正确,这无法和源代码映射
            urlPrefix: '~/qn/js'
        })
    )
}

// 事例
const config = {
  plugins: plugins,
};

vue2项目vue.config.js配置

const EmnjSentryWebpackPlugin = require('emnj-sentry-webpack-plugin');

const isBuildProd = process.env.BUILD_ENV == 'production';

module.exports = {
    chainWebpack: config => {
        if (isBuildProd) {
            // 生产环境配置
            // 1.配置sentry
            config.plugin('emnj-sentry-webpack-plugin').use(EmnjSentryWebpackPlugin, [
                {
                    // 建议每次发布一个生产版本,release版本变更一下  
                    release: '1.0.0',
                    org: "your org",
                    project: "your project",
                    // 重要:资源上传的url,不配置这是sentry官网的域名。
                    url: 'https://*******.com/',
                    // 重要:认证的token
                    authToken: '**********************',
                    // 只需要是打包后资源目录下的js和map文件
                    include: ['./dist/**/*.js', './dist/**/*.map'],
                    // 根目录下可以配置忽略上传的文件规则
                    ignoreFile: '.sentrycliignore',
                    ignore: ['node_modules', 'webpack.config.js'],
                    configFile: 'sentry.properties',
                    // 这个比较重要,未配置正确,这无法和源代码映射
                    urlPrefix: '~/qn/js'
                }
            ]);
        }
    }
}

更详细参考文档参考内部文档webpack构建上传sourcemaps

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago