Skip to content

Instantly share code, notes, and snippets.

@baio
Created October 23, 2017 22:22
Show Gist options
  • Save baio/da2ff78a51b16727c19677e84844c481 to your computer and use it in GitHub Desktop.
Save baio/da2ff78a51b16727c19677e84844c481 to your computer and use it in GitHub Desktop.
angular module build
# build librarys and place rsult to dist folder
# Clean up previous distributions if folders exist
if (Test-Path dist) {
Remove-Item dist -Recurse -Force
}
if (Test-Path build) {
Remove-Item build -Recurse -Force
}
# Variables
$NGC="node_modules/.bin/ngc"
$ROLLUP="node_modules/.bin/rollup"
$INLINE="node_modules/.bin/ng-asset-inline-fixed"
# Run Angular Compiler to ES5
& "$NGC" -p src/lib/tsconfig-es5.json
if (-Not $?) {
Throw "NGC Failed"
}
# Inline styles and html into componnets
& "$INLINE" build src/lib --styles src/sass
if (-Not $?) {
Throw "Inline Failed"
}
# Rollup modeus-core.js
& "$ROLLUP" build/modeus-core.js -o dist/modeus-core.js -f es
if (-Not $?) {
Throw "Rollup Failed"
}
# Quick dirty fix for /index fuck
# https://github.com/rollup/rollup/issues/1220
(Get-Content dist/modeus-core.js).replace('ng-click-outside/index', 'ng-click-outside') | Set-Content dist/modeus-core.js
(Get-Content dist/modeus-core.js).replace('ramda/index', 'ramda') | Set-Content dist/modeus-core.js
(Get-Content dist/modeus-core.js).replace('apollo-angular/index', 'apollo-angular') | Set-Content dist/modeus-core.js
if (-Not $?) {
Throw "Fix dist failed"
}
# Copy non-js files from build
Copy-Item -Exclude *.js -Recurse -Path build/* -Destination dist
if (-Not $?) {
Throw "Fix non js failed"
}
# Copy assets to dist
Copy-Item -Recurse -Path src/lib/assets/sass -Destination dist
Copy-Item -Recurse -Path src/fonts -Destination dist
if (-Not $?) {
Throw "Copy assets failed"
}
# Change font paths
(Get-Content dist/sass/base/typography.scss).replace('../fonts/', '/modeus_core/fonts/') | Set-Content dist/sass/base/typography.scss
if (-Not $?) {
Throw "Change font paths failed"
}
# Copy library package.json
Copy-Item -Path src/lib/package.json -Destination dist/package.json
Copy-Item -Path README.md -Destination dist/README.md
if (-Not $?) {
Throw "Copy lib stuff failed"
}
Write-Host "Build success"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment