Files
vercel/examples/aurelia/aurelia_project/tasks/run.js
Andy 890de6a625 Add API for frameworks and examples (#3514)
* Add API for frameworks and examples

* Adjust headers

* Update frameworks list

* Always use latest

* Add types

* Use now repo for downloading and listing

* Use .existsSync

* Remove unused packages

* Use 307 for redirect

* Add examples

* Update tsconfig.json

Co-Authored-By: Steven <steven@ceriously.com>

* Make examples unique

* Remove detectors from frameworks API

* Use /api instead of Next.js

* Install dependencies

* Rename project

* Change name

* Empty

* Change name

* Update api/tsconfig.json

Co-Authored-By: Steven <steven@ceriously.com>

* Update examples

Co-authored-by: Steven <steven@ceriously.com>
2020-01-07 23:55:39 +01:00

55 lines
1.8 KiB
JavaScript

import webpack from 'webpack';
import Server from 'webpack-dev-server';
import project from '../aurelia.json';
import gulp from 'gulp';
import { config } from './build';
import configureEnvironment from './environment';
import { CLIOptions, reportWebpackReadiness } from 'aurelia-cli';
function runWebpack(done) {
// https://webpack.github.io/docs/webpack-dev-server.html
let opts = {
host: 'localhost',
publicPath: config.output.publicPath,
filename: config.output.filename,
hot: project.platform.hmr || CLIOptions.hasFlag('hmr'),
port: CLIOptions.getFlagValue('port') || project.platform.port,
contentBase: config.output.path,
historyApiFallback: true,
open: project.platform.open || CLIOptions.hasFlag('open'),
stats: {
colors: require('supports-color'),
},
...config.devServer,
};
// Add the webpack-dev-server client to the webpack entry point
// The path for the client to use such as `webpack-dev-server/client?http://${opts.host}:${opts.port}/` is not required
// The path used is derived from window.location in the browser and output.publicPath in the webpack.config.
if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.entry.app.unshift(
'webpack-dev-server/client',
'webpack/hot/dev-server'
);
} else {
// removed "<script src="/webpack-dev-server.js"></script>" from index.ejs in favour of this method
config.entry.app.unshift('webpack-dev-server/client');
}
const compiler = webpack(config);
let server = new Server(compiler, opts);
server.listen(opts.port, opts.host, function(err) {
if (err) throw err;
reportWebpackReadiness(opts);
done();
});
}
const run = gulp.series(configureEnvironment, runWebpack);
export { run as default };