diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae84263..6caefcf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,8 +21,12 @@ jobs: - name: Install dependencies run: npm ci - - name: Run component tests - run: npm run test:component + - name: Cypress run + uses: cypress-io/github-action@v6 + with: + build: npm run build + start: npm run dev + browser: chrome + component: true env: - # Add any environment variables needed for tests - CI: true \ No newline at end of file + NODE_ENV: production \ No newline at end of file diff --git a/src/lib/useGetPolygons.ts b/src/lib/useGetPolygons.ts index 184c877..f8f8ec0 100644 --- a/src/lib/useGetPolygons.ts +++ b/src/lib/useGetPolygons.ts @@ -1,4 +1,4 @@ -// react hook that returns polygons data: +// react hook that returns polygons data import { useCallback } from 'react'; import { usePolygonContext } from './context/PolygonContext'; diff --git a/vite.config.ts b/vite.config.ts index 9802308..76f9d29 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,41 +6,51 @@ import { EsLinter, linterPlugin } from 'vite-plugin-linter'; import tsConfigPaths from 'vite-tsconfig-paths'; import * as packageJson from './package.json'; -export default defineConfig((configEnv) => ({ - plugins: [ +export default defineConfig((configEnv) => { + const plugins = [ dts({ insertTypesEntry: true, include: ['src/lib/'], }), react(), tsConfigPaths(), - linterPlugin({ - include: ['./src/**/*.{ts,tsx}'], - linters: [new EsLinter({ configEnv })], - }), - ], - build: { - lib: { - entry: path.join('src', 'lib/index.ts'), - name: 'polygon-annotation', - formats: ['es', 'umd'], - fileName: (format) => `polygon-annotation.${format}.js`, - }, - rollupOptions: { - external: [...Object.keys(packageJson.peerDependencies)], - output: { - globals: { - react: 'React', - 'react-dom': 'ReactDOM', + ]; + + // Only add linter in development + if (process.env.NODE_ENV !== 'production') { + plugins.push( + linterPlugin({ + include: ['./src/**/*.{ts,tsx}'], + linters: [new EsLinter({ configEnv })], + }) + ); + } + + return { + plugins, + build: { + lib: { + entry: path.join('src', 'lib/index.ts'), + name: 'polygon-annotation', + formats: ['es', 'umd'], + fileName: (format) => `polygon-annotation.${format}.js`, + }, + rollupOptions: { + external: [...Object.keys(packageJson.peerDependencies)], + output: { + globals: { + react: 'React', + 'react-dom': 'ReactDOM', + }, }, }, }, - }, - test: { - deps: { - web: { - transformAssets: true, + test: { + deps: { + web: { + transformAssets: true, + }, }, }, - }, -})); + }; +});