diff --git a/change/@microsoft-fast-tooling-bcd2decc-c311-487f-8036-af419f9b0ea5.json b/change/@microsoft-fast-tooling-bcd2decc-c311-487f-8036-af419f9b0ea5.json new file mode 100644 index 00000000000..bd541a751d0 --- /dev/null +++ b/change/@microsoft-fast-tooling-bcd2decc-c311-487f-8036-af419f9b0ea5.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "add a script and files for running the manual testing app on a server", + "packageName": "@microsoft/fast-tooling", + "email": "7559015+janechu@users.noreply.github.com", + "dependentChangeType": "none" +} diff --git a/packages/tooling/fast-tooling/app/server.js b/packages/tooling/fast-tooling/app/server.js new file mode 100644 index 00000000000..5c1eb9a8571 --- /dev/null +++ b/packages/tooling/fast-tooling/app/server.js @@ -0,0 +1,15 @@ +var express = require("express"); +var path = require("path"); + +// Create application +var app = express(); + +// Set public directory +var publicDir = path.resolve(__dirname); + +// Set static application options +app.use("/", express.static(publicDir, { maxAge: "0d" })); + +// Serve up application on specified port +var port = process.env.PORT || 7001; +app.listen(port); diff --git a/packages/tooling/fast-tooling/app/webpack.common.js b/packages/tooling/fast-tooling/app/webpack.common.js index a7072bb9387..7e4b05a4bdd 100644 --- a/packages/tooling/fast-tooling/app/webpack.common.js +++ b/packages/tooling/fast-tooling/app/webpack.common.js @@ -5,6 +5,7 @@ const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const CopyWebpackPlugin = require("copy-webpack-plugin"); const appDir = path.resolve(__dirname, "./"); const outDir = path.resolve(__dirname, "../www"); @@ -89,5 +90,13 @@ module.exports = { languages: ["html"], features: ["format", "coreCommands", "codeAction"], }), + new CopyWebpackPlugin({ + patterns: [ + { + from: path.resolve(__dirname, "./server.js"), + to: path.resolve(__dirname, "../www/"), + }, + ], + }), ], }; diff --git a/packages/tooling/fast-tooling/package.json b/packages/tooling/fast-tooling/package.json index dbd44918509..ffe99171662 100644 --- a/packages/tooling/fast-tooling/package.json +++ b/packages/tooling/fast-tooling/package.json @@ -19,6 +19,7 @@ "types": "dist/dts/index.d.ts", "scripts": { "build": "yarn build:esm && yarn build:cjs && yarn build:message-system", + "build:app": "yarn build:message-system && webpack --progress --mode=production", "build:esm": "tsc -p ./tsconfig.esm.json", "build:cjs": "tsc -p ./tsconfig.cjs.json", "build:message-system": "webpack --config webpack.message-system.config.js", @@ -48,19 +49,23 @@ "devDependencies": { "@types/chai": "^4.2.11", "@types/karma": "^5.0.0", - "@types/mocha": "^7.0.2", "@types/lodash-es": "^4.17.4", + "@types/mocha": "^7.0.2", "@types/node": "^9.6.7", "ajv": "^6.10.0", "chai": "^4.2.0", "chai-spies": "^1.0.0", "clean-webpack-plugin": "^3.0.0", + "copy-webpack-plugin": "^6.0.0", "css-loader": "^4.2.0", "eslint-config-prettier": "^6.10.1", + "express": "4.17.1", "file-loader": "^6.0.0", "html-webpack-plugin": "^3.2.0", "istanbul": "^0.4.5", "istanbul-instrumenter-loader": "^3.0.1", + "jsdom": "^16.2.2", + "jsdom-global": "3.0.2", "karma": "^5.0.4", "karma-chrome-launcher": "^3.1.0", "karma-coverage": "^2.0.2", @@ -72,8 +77,6 @@ "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^4.0.2", "lodash-es": "4.17.15", - "jsdom": "^16.2.2", - "jsdom-global": "3.0.2", "mdn-data": "^2.0.11", "mini-css-extract-plugin": "^0.9.0", "mocha": "^7.1.2", @@ -95,8 +98,8 @@ "dependencies": { "@microsoft/fast-colors": "^5.1.3", "@microsoft/fast-components": "latest", - "@microsoft/fast-foundation": "latest", "@microsoft/fast-element": "latest", + "@microsoft/fast-foundation": "latest", "@microsoft/fast-web-utilities": "^4.7.3", "vscode-html-languageservice": "^3.1.3" } diff --git a/packages/tooling/fast-tooling/webpack.config.js b/packages/tooling/fast-tooling/webpack.config.js index b916156ce61..5e0de43f558 100644 --- a/packages/tooling/fast-tooling/webpack.config.js +++ b/packages/tooling/fast-tooling/webpack.config.js @@ -3,38 +3,39 @@ const glob = require("glob"); const rootAppWebpackConfig = require(path.resolve(__dirname, "app/webpack.dev.js")); const outDir = path.resolve(__dirname, "./www"); -const configs = new Promise((resolver) => { +const configs = new Promise(resolver => { try { - glob(`${path.resolve(__dirname, "./app/examples")}/*/webpack.dev.js`, {}, function (err, files) { - if (err) { - throw err; - } + glob( + `${path.resolve(__dirname, "./app/examples")}/*/webpack.dev.js`, + {}, + function (err, files) { + if (err) { + throw err; + } - resolver( - files.map((file) => { - const webpackConfig = require(file); - const name = path.basename(path.dirname(file)); + resolver( + files.map(file => { + const webpackConfig = require(file); + const name = path.basename(path.dirname(file)); - webpackConfig.name = name; - webpackConfig.output = { - ...webpackConfig.output, - path: path.resolve(outDir, name), - publicPath: `${name}/`, - } + webpackConfig.name = name; + webpackConfig.output = { + ...webpackConfig.output, + path: path.resolve(outDir, name), + publicPath: `/${name}/`, + }; - return webpackConfig; - }) - ); - }); + return webpackConfig; + }) + ); + } + ); } catch (err) { console.info(`No example app webpack files found`, err); process.exit(0); } -}).then((webpackConfigs) => { - return [ - rootAppWebpackConfig, - ...webpackConfigs - ]; +}).then(webpackConfigs => { + return [rootAppWebpackConfig, ...webpackConfigs]; }); module.exports = configs; diff --git a/yarn.lock b/yarn.lock index b1dea283412..c435dc209f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8576,7 +8576,7 @@ copy-webpack-plugin@^5.1.1: serialize-javascript "^4.0.0" webpack-log "^2.0.0" -copy-webpack-plugin@^6.0.3, copy-webpack-plugin@^6.3.0: +copy-webpack-plugin@^6.0.0, copy-webpack-plugin@^6.0.3, copy-webpack-plugin@^6.3.0: version "6.4.1" resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-6.4.1.tgz#138cd9b436dbca0a6d071720d5414848992ec47e" integrity sha512-MXyPCjdPVx5iiWyl40Va3JGh27bKzOTNY3NjUTrosD2q7dR/cLD0013uqJ3BpFbUjyONINjb6qI7nDIJujrMbA== @@ -10858,7 +10858,7 @@ expect@^25.5.0: jest-message-util "^25.5.0" jest-regex-util "^25.2.6" -express@^4.16.3, express@^4.17.1: +express@4.17.1, express@^4.16.3, express@^4.17.1: version "4.17.1" resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==