diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4a746e2b..9ff24ad1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,3 +52,16 @@ Unit tests and end-to-end tests are available in the `tests/` folder. `npx playwright install --with-deps` - Run tests (Chromium only): `npm run test:e2e` - Run tests (Chromium, Firefox & Webkit): `npm run test:e2e:ci` + +## Previewing Pull Requests + +Active pull requests on the polyfill can be tested using the built version +hosted within the preview environment. + +> **IMPORTANT** +> +> These previews are ephemeral, and will stop working after the pull request is +> merged. Do not use this for any purpose other than testing the pull request. + +All polyfills are located at the root of the preview environment. For instance, the CommonJS functional version for PR 123 would be available at +https://deploy-preview-123--anchor-polyfill.netlify.app/css-anchor-positioning-fn.umd.cjs. diff --git a/netlify.toml b/netlify.toml index 05169b68..6cb450a8 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,8 @@ [build] # If the $WPT_ONLY env var is set, only build branches that end with `--wpt-results` ignore = "if [[ ! $WPT_ONLY || $BRANCH == *--wpt-results ]]; then exit 1; else exit 0; fi" +[[headers]] + for = "/css-anchor-positioning*" # Only allow for polyfill files + [headers.values] + access-control-allow-origin = "*" + content-type = "text/javascript" diff --git a/package.json b/package.json index 3e8df732..ceb8b2bd 100644 --- a/package.json +++ b/package.json @@ -49,10 +49,11 @@ "package.json" ], "scripts": { - "build": "run-s build:dist build:fn", + "build": "run-s build:demo build:dist build:fn", "build:dist": "vite build", "build:fn": "cross-env BUILD_FN=1 vite build", "build:wpt": "cross-env BUILD_WPT=1 vite build", + "build:demo": "cross-env BUILD_DEMO=1 vite build", "preview": "vite preview", "serve": "vite dev", "tsc": "tsc --noEmit", diff --git a/vite.config.ts b/vite.config.ts index 0961f58c..7f1161b4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -8,7 +8,7 @@ export default defineConfig({ server: { port: 3000, }, - build: process.env.NETLIFY + build: process.env.BUILD_DEMO ? {} : { lib: process.env.BUILD_WPT @@ -35,7 +35,7 @@ export default defineConfig({ // the proper extensions will be added fileName: 'css-anchor-positioning', }, - emptyOutDir: !process.env.BUILD_FN, + emptyOutDir: false, target: 'es6', sourcemap: true, rollupOptions: {