Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
NODE_ENV: production
2 changes: 1 addition & 1 deletion src/lib/useGetPolygons.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
64 changes: 37 additions & 27 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
},
}));
};
});