chore(build): improve angular build scripts

This commit is contained in:
Adam Bradley
2018-05-22 23:24:18 -05:00
parent cdada12c94
commit c35684e165
6 changed files with 2542 additions and 19 deletions

View File

@@ -1,13 +1,11 @@
# Local @ionic/angular test app development
# Local @ionic/angular test/testapp development
1. `npm install` at the root of `angular`
2. `npm run build` to build local `@ionic/angular`
3. `npm link` to locally link `@ionic/angular`
4. `cd` to the test app, such as `angular/test/nav`
5. `npm install` in the test app directory
6. `npm link @ionic/angular` in the test app directory
7. `ng serve` in the test app directory
8. [http://localhost:4200/](http://localhost:4200/)
2. `npm run build.dev` to build local `@ionic/angular` and `@ionic/core`
3. `cd test/testapp` to the test app
4. `npm install` in the test app directory
5. `npm run serve` copies packages and serve the app (see package.json for more options)
6. [http://localhost:4200/](http://localhost:4200/)
# npm link local development

74
angular/scripts/build-core.js vendored Normal file
View File

@@ -0,0 +1,74 @@
const fs = require('fs-extra');
const path = require('path');
const spawn = require('child_process').spawn;
const stencilPath = path.join(__dirname, '..', '..', 'core', 'node_modules', '.bin');
function buildIonicAngular() {
const cmd = 'stencil';
const args = [
'build',
'--config',
path.join(__dirname, '..', 'stencil.config.js'),
...process.argv.slice(2)
];
console.log(cmd, args.join(' '));
const p = spawn('stencil', args, { cwd: stencilPath, stdio: 'inherit' });
p.on('close', (code) => {
if (code > 0) {
console.log(`@ionic/angular build exited with ${code}`);
}
});
}
function buildIonicCore() {
const cmd = 'stencil';
const args = [
'build',
'--config',
path.join(__dirname, '..', '..', 'core', 'stencil.config.js'),
...process.argv.slice(2)
];
console.log(cmd, args.join(' '));
const p = spawn('stencil', args, { cwd: stencilPath, stdio: 'inherit' });
p.on('close', (code) => {
if (code > 0) {
console.log(`@ionic/core build exited with ${code}`);
} else {
copyIonicCore();
copyIonicons();
}
});
}
function copyIonicons() {
const src = path.join(__dirname, '..', '..', 'core', 'node_modules', 'ionicons');
const dst = path.join(__dirname, '..', 'node_modules', 'ionicons');
fs.emptyDirSync(dst);
fs.copySync(src, dst);
}
function copyIonicCore() {
const srcDir = path.join(__dirname, '..', '..', 'core');
const dstDir = path.join(__dirname, '..', 'node_modules', '@ionic', 'core');
fs.emptyDirSync(dstDir);
const srcPkg = path.join(srcDir, 'package.json');
const dstPkg = path.join(dstDir, 'package.json');
fs.copySync(srcPkg, dstPkg);
const srcDist = path.join(srcDir, 'dist');
const dstDist = path.join(dstDir, 'dist');
fs.emptyDirSync(dstDist);
fs.copySync(srcDist, dstDist);
}
buildIonicCore();
buildIonicAngular();

View File

@@ -1,5 +0,0 @@
#!/bin/sh
rm -rf ./node_modules/ionicons
cp -a ../core/node_modules/ionicons ./node_modules/ionicons
../core/node_modules/.bin/stencil build