Skip to content

Commit

Permalink
refactor: use vite instead of webpack (#189)
Browse files Browse the repository at this point in the history
Resulting library is at 5710 bytes uncompressed.
  • Loading branch information
sk- authored Aug 2, 2023
1 parent 213a165 commit ba3f2e4
Show file tree
Hide file tree
Showing 8 changed files with 2,277 additions and 855 deletions.
3,005 changes: 2,236 additions & 769 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"homepage": "https://github.com/Topsort/analytics.js#readme",
"scripts": {
"prepublishOnly": "npm run build && node update-version.js",
"build": "webpack",
"build": "vite build",
"test": "jest",
"test:e2e": "webpack && webpack -c webpack.config.browser-test.js && tsc && cp dist/mocks/api-server.{,m}js && node dist/mocks/api-server.mjs",
"test:e2e": "vite build && vite build -c vite.config.browser-test.js && tsc && cp dist/mocks/api-server.{,m}js && node dist/mocks/api-server.mjs",
"lint": "eslint . --max-warnings 0 --ignore-path .gitignore",
"lint:fix": "npm run lint -- --fix",
"lint:ci": "npm run lint -- --format=compact",
Expand All @@ -30,6 +30,7 @@
"@types/react-dom": "^18.0.10",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.54.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^27.2.2",
Expand All @@ -46,7 +47,7 @@
"ts-jest": "^27.1.4",
"ts-loader": "^9.4.2",
"typescript": "^4.8.4",
"webpack": "^5.86.0",
"webpack-cli": "^5.0.1"
"vite": "^4.4.7",
"vite-plugin-html": "^3.2.0"
}
}
2 changes: 1 addition & 1 deletion tests/real_e2e.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
url: "https://ts-ohio.api.staging.topsort.ai",
};
</script>
<script src="../dist/ts.js"></script>
<script src="../dist/ts.umd.js"></script>
</head>
<body>
<!-- Promoted Product -->
Expand Down
4 changes: 2 additions & 2 deletions tests/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
url: window.location.origin + "/" + testId,
};
</script>
<script src="/js/ts.js"></script>
<script src="/js/test-bundle-react.js"></script>
<script src="/js/ts.umd.js"></script>
<script src="/js/test-bundle-react.umd.js"></script>
<script src="/js/tests/browser-test.js"></script>
</html>
18 changes: 18 additions & 0 deletions vite.config.browser-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { resolve } from "path";
import { defineConfig } from "vite";

export default defineConfig({
build: {
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "tests/components.tsx"),
name: "test-bundle-react",
// the proper extensions will be added
fileName: "test-bundle-react",
},
emptyOutDir: false,
},
define: {
"process.env.NODE_ENV": "'production'",
},
});
15 changes: 15 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { resolve } from "path";
import { defineConfig } from "vite";

export default defineConfig({
build: {
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/detector.ts"),
name: "ts",
// the proper extensions will be added
fileName: "ts",
},
emptyOutDir: false,
},
});
23 changes: 0 additions & 23 deletions webpack.config.browser-test.js

This file was deleted.

56 changes: 0 additions & 56 deletions webpack.config.js

This file was deleted.

0 comments on commit ba3f2e4

Please sign in to comment.