From 974181d4db176ccbcb66d783dd0ed41b62854dd1 Mon Sep 17 00:00:00 2001 From: Alex LaFroscia Date: Wed, 14 Apr 2021 18:18:13 -0400 Subject: [PATCH] WIP: test the `static-app` with Vite --- test-packages/static-app/ember-cli-build.js | 19 +++++++++++++++++-- test-packages/static-app/package.json | 10 +++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/test-packages/static-app/ember-cli-build.js b/test-packages/static-app/ember-cli-build.js index ad836061eb..627ad038c1 100644 --- a/test-packages/static-app/ember-cli-build.js +++ b/test-packages/static-app/ember-cli-build.js @@ -14,9 +14,24 @@ module.exports = function (defaults) { return app.toTree(); } - const Webpack = require('@embroider/webpack').Webpack; - return require('@embroider/compat').compatBuild(app, Webpack, { + let packager; + + if (process.env.PACKAGER === 'webpack') { + packager = require('@embroider/webpack').Webpack; + } else if (process.env.PACKAGER === 'vite') { + packager = require('@embroider/vite').Vite; + } else if (process.env.PACKAGER) { + throw new Error(`$PACKAGER ${process.env.PACKAGER} not recognised`); + } else { + throw new Error(`$PACKAGER is missing`); + } + + return require('@embroider/compat').compatBuild(app, packager, { workspaceDir: process.env.WORKSPACE_DIR, + viteConfig: { + sourcemap: 'inline', + logLevel: 'info', + }, staticAddonTestSupportTrees: true, staticAddonTrees: true, staticComponents: true, diff --git a/test-packages/static-app/package.json b/test-packages/static-app/package.json index 82af92cab2..9546d0b251 100644 --- a/test-packages/static-app/package.json +++ b/test-packages/static-app/package.json @@ -17,10 +17,13 @@ "lint:js": "eslint .", "start": "ember serve", "test": "npm-run-all lint:* test:*", - "test:ember": "ember test --test-port=0", "test:ember-classic": "cross-env CLASSIC=true ember test --test-port=0", - "test:custom-root": "cross-env CUSTOM_ROOT_URL=/custom/ ember test --test-port=0", - "test:custom-relative-root": "cross-env CUSTOM_ROOT_URL=custom-relative-root-url/ ember test --test-port=0" + "test:webpack": "cross-env PACKAGER=webpack ember test --test-port=0", + "test:webpack-custom-root": "cross-env PACKAGER=webpack CUSTOM_ROOT_URL=/custom/ ember test --test-port=0", + "test:webpack-custom-relative-root": "cross-env PACKAGER=webpack CUSTOM_ROOT_URL=custom-relative-root-url/ ember test --test-port=0", + "test:vite": "cross-env PACKAGER=vite ember test --test-port=0", + "test:vite-custom-root": "cross-env PACKAGER=vite CUSTOM_ROOT_URL=/custom/ ember test --test-port=0", + "test:vite-custom-relative-root": "cross-env PACKAGER=vite CUSTOM_ROOT_URL=custom-relative-root-url/ ember test --test-port=0" }, "devDependencies": { "@ember/jquery": "^0.5.2", @@ -29,6 +32,7 @@ "@embroider/core": "0.39.1", "@embroider/macros": "0.39.1", "@embroider/test-support": "0.36.0", + "@embroider/vite": "0.39.1", "@embroider/webpack": "0.39.1", "broccoli-asset-rev": "^3.0.0", "ember-ajax": "^5.0.0",