From 8adfea28b606fb10e0e4f7d0dd3039a534f8a352 Mon Sep 17 00:00:00 2001 From: Joe McGrath Date: Thu, 2 Dec 2021 14:55:54 +0900 Subject: [PATCH] fix(webpack): remove test attributes from build remove dta-cy attributes on nuxt build closes #49 --- nuxt.config.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/nuxt.config.js b/nuxt.config.js index d7bcb8eb80..d409e7e519 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -161,11 +161,29 @@ export default defineNuxtConfig({ // Build Configuration: https://go.nuxtjs.dev/config-build build: { - extend(config) { + extend(config, ctx) { config.node = { fs: 'empty', encoding: 'empty', } + const testAttributes = ['data-cy'] + ctx.loaders.vue.compilerOptions = { + modules: [ + { + preTransformNode(astEl) { + const { attrsMap, attrsList } = astEl + testAttributes.forEach((attribute) => { + if (attrsMap[attribute]) { + delete attrsMap[attribute] + const index = attrsList.findIndex((x) => x.name === attribute) + attrsList.splice(index, 1) + } + }) + return astEl + }, + }, + ], + } }, babel: { compact: true }, },