From 0293076c31588e6782665e34bc4aba516cb891fd Mon Sep 17 00:00:00 2001 From: Allen Zhang <37892968+zhangtao25@users.noreply.github.com> Date: Tue, 22 Oct 2024 00:36:13 +0800 Subject: [PATCH] feat(swc-plugin-canyon): update readme --- plugins/swc-plugin-canyon/README.md | 32 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/plugins/swc-plugin-canyon/README.md b/plugins/swc-plugin-canyon/README.md index 556c7c62..c3cdf4e5 100644 --- a/plugins/swc-plugin-canyon/README.md +++ b/plugins/swc-plugin-canyon/README.md @@ -12,15 +12,36 @@ Install it: npm install --save-dev swc-plugin-istanbul ``` -Add it to `swc.config.js` in test mode: +Add it to `next.config.mjs` in test mode: ```js -module.exports = { - plugins: - process.env.CI_COMMIT_REF_NAME === 'test-coverage'? ['istanbul', 'canyon']:[] -} +/** @type {import('next').NextConfig} */ +const nextConfig = { + experimental: { + swcPlugins: [ + [ + 'swc-plugin-coverage-instrument', {}, + 'swc-plugin-canyon', + { + dsn: 'http://yourdomain.com/coverage/client', + reporter: 'your_token', + projectID: '230614', + sha: 'xxxxxxxxx', + reportID: 'case_id', + branch: 'master', + compareTarget: 'develop', + }, + ], + ], + }, + }; + +export default nextConfig; ``` +查看 [Example](https://github.com/canyon-project/canyon/blob/main/examples/next-swc/next.config.mjs) + + ## Configuration swc.config.js @@ -55,4 +76,3 @@ module.exports = { | reportID | Report ID, Used to distinguish between different test cases. | Optional | | branch | Git repository branch, the plugin will detect the variables of the pipeline, which usually don't need to be configured. | Optional | | compareTarget | Compare target, used as a baseline against current sha to calculate change line coverage. | Optional | -