diff --git a/.gitignore b/.gitignore index 0fcd9b68bf..af590a8ade 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ dist # vscode .vscode/* !.vscode/extensions.json +!.vscode/launch.json +!.vscode/tasks.json # Cast dev settings src/cast/dev_const.ts diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..e36792ce4c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,41 @@ +{ + // https://github.com/microsoft/vscode-js-debug/blob/master/OPTIONS.md + "configurations": [ + { + "name": "Debug Frontend", + "request": "launch", + "type": "pwa-chrome", + "url": "http://localhost:8123/", + "webRoot": "${workspaceFolder}/hass_frontend", + "disableNetworkCache": true, + "preLaunchTask": "Develop Frontend", + }, + { + "name": "Debug Gallery", + "request": "launch", + "type": "pwa-chrome", + "url": "http://localhost:8100/", + "webRoot": "${workspaceFolder}/gallery/dist", + "disableNetworkCache": true, + "preLaunchTask": "Develop Gallery" + }, + { + "name": "Debug Demo", + "request": "launch", + "type": "pwa-chrome", + "url": "http://localhost:8090/", + "webRoot": "${workspaceFolder}/demo/dist", + "disableNetworkCache": true, + "preLaunchTask": "Develop Demo" + }, + { + "name": "Debug Cast", + "request": "launch", + "type": "pwa-chrome", + "url": "http://localhost:8080/", + "webRoot": "${workspaceFolder}/cast/dist", + "disableNetworkCache": true, + "preLaunchTask": "Develop Cast" + }, + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..d23faf6995 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,137 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Develop Frontend", + "type": "gulp", + "task": "develop-app", + // Sync changes here to other tasks until issue resolved + // https://github.com/Microsoft/vscode/issues/61497 + "problemMatcher": { + "owner": "ha-build", + "source": "ha-build", + "fileLocation": "absolute", + "severity": "error", + "pattern": [ + { + "regexp": "(SyntaxError): (.+): (.+) \\((\\d+):(\\d+)\\)", + "severity": 1, + "file": 2, + "message": 3, + "line": 4, + "column": 5 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "Changes detected. Starting compilation", + "endsPattern": "Build done @" + } + }, + "isBackground": true, + "group": { + "kind": "build", + "isDefault": true + }, + "runOptions": { + "instanceLimit": 1 + } + }, + { + "label": "Develop Gallery", + "type": "gulp", + "task": "develop-gallery", + "problemMatcher": { + "owner": "ha-build", + "source": "ha-build", + "fileLocation": "absolute", + "severity": "error", + "pattern": [ + { + "regexp": "(SyntaxError): (.+): (.+) \\((\\d+):(\\d+)\\)", + "severity": 1, + "file": 2, + "message": 3, + "line": 4, + "column": 5 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "Changes detected. Starting compilation", + "endsPattern": "Build done @" + } + }, + + "isBackground": true, + "group": "build", + "runOptions": { + "instanceLimit": 1 + } + }, + { + "label": "Develop Demo", + "type": "gulp", + "task": "develop-demo", + "problemMatcher": { + "owner": "ha-build", + "source": "ha-build", + "fileLocation": "absolute", + "severity": "error", + "pattern": [ + { + "regexp": "(SyntaxError): (.+): (.+) \\((\\d+):(\\d+)\\)", + "severity": 1, + "file": 2, + "message": 3, + "line": 4, + "column": 5 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "Changes detected. Starting compilation", + "endsPattern": "Build done @" + } + }, + + "isBackground": true, + "group": "build", + "runOptions": { + "instanceLimit": 1 + } + }, + { + "label": "Develop Cast", + "type": "gulp", + "task": "develop-cast", + "problemMatcher": { + "owner": "ha-build", + "source": "ha-build", + "fileLocation": "absolute", + "severity": "error", + "pattern": [ + { + "regexp": "(SyntaxError): (.+): (.+) \\((\\d+):(\\d+)\\)", + "severity": 1, + "file": 2, + "message": 3, + "line": 4, + "column": 5 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": "Changes detected. Starting compilation", + "endsPattern": "Build done @" + } + }, + + "isBackground": true, + "group": "build", + "runOptions": { + "instanceLimit": 1 + } + }, + ] +} diff --git a/build-scripts/gulp/webpack.js b/build-scripts/gulp/webpack.js index 38fba59640..dc6570ba4e 100644 --- a/build-scripts/gulp/webpack.js +++ b/build-scripts/gulp/webpack.js @@ -18,6 +18,14 @@ const bothBuilds = (createConfigFunc, params) => [ createConfigFunc({ ...params, latestBuild: false }), ]; +/** + * @param {{ + * compiler: import("webpack").Compiler, + * contentBase: string, + * port: number, + * listenHost?: string + * }} + */ const runDevServer = ({ compiler, contentBase, @@ -33,7 +41,10 @@ const runDevServer = ({ throw err; } // Server listening - log("[webpack-dev-server]", `http://localhost:${port}`); + log( + "[webpack-dev-server]", + `Project is running at http://localhost:${port}` + ); }); const handler = (done) => (err, stats) => { @@ -45,12 +56,12 @@ const handler = (done) => (err, stats) => { return; } - log(`Build done @ ${new Date().toLocaleTimeString()}`); - if (stats.hasErrors() || stats.hasWarnings()) { - log.warn(stats.toString("minimal")); + console.log(stats.toString("minimal")); } + log(`Build done @ ${new Date().toLocaleTimeString()}`); + if (done) { done(); } diff --git a/build-scripts/paths.js b/build-scripts/paths.js index ab1b6d3853..ae613b9b10 100644 --- a/build-scripts/paths.js +++ b/build-scripts/paths.js @@ -1,4 +1,4 @@ -var path = require("path"); +const path = require("path"); module.exports = { polymer_dir: path.resolve(__dirname, ".."), diff --git a/build-scripts/webpack.js b/build-scripts/webpack.js index 65d4287a34..d29521ce35 100644 --- a/build-scripts/webpack.js +++ b/build-scripts/webpack.js @@ -4,6 +4,21 @@ const TerserPlugin = require("terser-webpack-plugin"); const ManifestPlugin = require("webpack-manifest-plugin"); const paths = require("./paths.js"); const bundle = require("./bundle"); +const log = require("fancy-log"); + +class LogStartCompilePlugin { + ignoredFirst = false; + + apply(compiler) { + compiler.hooks.beforeCompile.tap("LogStartCompilePlugin", () => { + if (!this.ignoredFirst) { + this.ignoredFirst = true; + return; + } + log("Changes detected. Starting compilation"); + }); + } +} const createWebpackConfig = ({ entry, @@ -104,7 +119,8 @@ const createWebpackConfig = ({ ), path.resolve(paths.polymer_dir, "src/resources/EventTarget-ponyfill.js") ), - ], + !isProdBuild && new LogStartCompilePlugin(), + ].filter(Boolean), resolve: { extensions: [".ts", ".js", ".json"], },