Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 {
pluginJson('dist/native-modules'),
buildPluginJavaScript('dist/native-modules', 'es2015'),
// package.json "main" field pointing to dist/native-modules/index.js
pluginMarkup('dist/commonjs'),
pluginCSS('dist/commonjs'),
pluginJson('dist/commonjs'),
buildPluginJavaScript('dist/commonjs', 'commonjs'),
), (done) => {
console.log('Finish building Aurelia plugin to dist/commonjs and dist/native-modules.');
done();
}
);
let main;
if (CLIOptions.hasFlag('watch')) {
main = gulp.series(
clean,
() => {
console.log('Watching plugin sources for changes ...');
return gulp.watch('src/**/*', { ignoreInitial: false }, build);
}
);
} else {
main = gulp.series(
clean,
build
);
}
export { main as default };
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: project.platform.port,
contentBase: config.output.path,
historyApiFallback: true,
open: project.platform.open,
stats: {
colors: require('supports-color')
},
https: config.devServer.https
} as any;
// 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');
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: project.platform.port,
contentBase: config.output.path,
historyApiFallback: true,
open: project.platform.open,
stats: {
colors: require('supports-color')
},
https: config.devServer.https
} as any;
if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.entry.app.unshift(`webpack-dev-server/client?http://${opts.host}:${opts.port}/`, 'webpack/hot/dev-server');
}
const compiler = webpack(config);
export default function processMarkup() {
return gulp.src(project.markupProcessor.source, {sourcemaps: true, since: gulp.lastRun(processMarkup)})
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
ignoreCustomFragments: [/\${.*?}/g] // ignore interpolation expressions
}))
.pipe(build.bundle());
}
function buildJavaScript() {
let transpile = babel(project.transpiler.options);
if (useCache) {
// the cache directory is "gulp-cache/projName-env" inside folder require('os').tmpdir()
// use command 'au clear-cache' to purge all caches
transpile = cache(transpile, {name: project.name + '-' + env});
}
return gulp.src(project.transpiler.source, {sourcemaps: true, since: gulp.lastRun(buildJavaScript)})
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(transpile)
.pipe(build.bundle());
}
function configureEnvironment() {
let env = CLIOptions.getEnvironment();
return gulp.src(`aurelia_project/environments/${env}${project.transpiler.fileExtension}`)
.pipe(rename(`environment${project.transpiler.fileExtension}`))
.pipe(gulp.dest(project.paths.root))
.pipe(through.obj(function (file, enc, cb) {
// https://github.com/webpack/watchpack/issues/25#issuecomment-287789288
var now = Date.now() / 1000;
var then = now - 10;
fs.utimes(file.path, then, then, function (err) { if (err) throw err });
cb(null, file);
}));
}
import gulp from 'gulp';
import plumber from 'gulp-plumber';
import babel from 'gulp-babel';
import notify from 'gulp-notify';
import rename from 'gulp-rename';
import cache from 'gulp-cache';
import project from '../aurelia.json';
import {CLIOptions, build, Configuration} from 'aurelia-cli';
let env = CLIOptions.getEnvironment();
const buildOptions = new Configuration(project.build.options);
const useCache = buildOptions.isApplicable('cache');
function configureEnvironment() {
return gulp.src(`aurelia_project/environments/${env}.js`, {since: gulp.lastRun(configureEnvironment)})
.pipe(rename('environment.js'))
.pipe(gulp.dest(project.paths.root));
}
function buildJavaScript() {
let transpile = babel(project.transpiler.options);
if (useCache) {
// the cache directory is "gulp-cache/projName-env" inside folder require('os').tmpdir()
// use command 'au clear-cache' to purge all caches
transpile = cache(transpile, {name: project.name + '-' + env});
}
import gulp from 'gulp';
import plumber from 'gulp-plumber';
import babel from 'gulp-babel';
import notify from 'gulp-notify';
import rename from 'gulp-rename';
import cache from 'gulp-cache';
import project from '../aurelia.json';
import {CLIOptions, build, Configuration} from 'aurelia-cli';
let env = CLIOptions.getEnvironment();
const buildOptions = new Configuration(project.build.options);
const useCache = buildOptions.isApplicable('cache');
function configureEnvironment() {
return gulp.src(`aurelia_project/environments/${env}.js`, {since: gulp.lastRun(configureEnvironment)})
.pipe(rename('environment.js'))
.pipe(gulp.dest(project.paths.root));
}
function buildJavaScript() {
let transpile = babel(project.transpiler.options);
if (useCache) {
// the cache directory is "gulp-cache/projName-env" inside folder require('os').tmpdir()
// use command 'au clear-cache' to purge all caches
transpile = cache(transpile, {name: project.name + '-' + env});
}
function configureEnvironment() {
let env = CLIOptions.getEnvironment();
return gulp.src(`aurelia_project/environments/${env}.ts`, {since: gulp.lastRun(configureEnvironment)})
.pipe(rename('environment.ts'))
.pipe(through.obj(function (file, _, cb) {
// https://github.com/aurelia/cli/issues/1031
fs.unlink(`${project.paths.root}/${file.relative}`, function () { cb(null, file); });
}))
.pipe(gulp.dest(project.paths.root));
}