Conversation
| let target; | ||
| if (Array.isArray(targets)) { | ||
| target = targets[0]; | ||
| target.legacy = true; |
There was a problem hiding this comment.
Perhaps I'm missing something, but is this always going to return the first target if the project.build.targets is in fact an array?
Do you perhaps have an example of what the structure should look like?
My aurelia.json currently looks like this:
"build": {
"targets": [
{
"id": "web",
"displayName": "Web",
"index": "index.html",
"baseDir": ".",
"output": "scripts"
},
{
"id": "kiosk",
"displayName": "Kiosk",
"index": "kiosk.html",
"baseDir": ".",
"output": "kiosk_scripts"
}
]
There was a problem hiding this comment.
@johan-v-r You're not missing something; that is the current behaviour (which is kept so that it's a non-breaking change).
Here's a (somewhat long) example:
"targets": {
"web": {
"id": "web",
"displayName": "Web",
"index": "index.html",
"output": "scripts",
"root": "dist/${TARGET}/${ENV}",
"resources": [
"favicon.ico",
"images/**",
"styles/**"
],
"environments": {
"dev": {
"root": "build/dev"
}
}
},
"aspnetcore": {
"id": "aspnetcore",
"displayName": "ASP.NET Core",
"index": "index.html",
"output": "scripts",
"root": "wwwroot",
"resources": [
"favicon.ico",
"images/**",
"styles/**"
],
"environments": {
"prod": {
"root": "../dotnetcore/wwwroot"
}
}
},
"cordova": {
"id": "cordova",
"displayName": "Cordova",
"index": "index.html",
"indexSource": "index.cordova.html",
"output": "scripts",
"root": "../cordova/www",
"resources": [
"favicon.ico",
"images/**",
"styles/**"
]
},
"EXTERNAL": "aspnetcore & cordova",
"ALL": "web & EXTERNAL"
}
In this example the Aurelia project also contains a dotnet core web server/project (not really a good idea, but it's just an example) that will be targeted for dev and stage builds. In addition, the Aurelia project has two "sibling projects", one Cordova and one that's, again, dotnet core (which is targeted for the prod build). The Cordova project has additional requirements for index.html, so it's a separate file in the Aurelia project (that will be renamed to index.html for the target).
Running
au build --target ALL --watch
will rebuild and update all three targets as soon as a file is changed.
There was a problem hiding this comment.
Okay yeah thanks this is awesome, will 100% work for me. This also replaces my PR #731
Just a final note from my side, looks like root property is more like an output directory..? Can/should this name perhaps be changed?
There was a problem hiding this comment.
@johan-v-r Well, it is the target root and the base for the other target settings. (And, depending on them, nothing might actually end up there.) Plus, I didn't want it mixed up with the current output (which is where the script bundles are put). But yeah, perhaps it should be changed (but then output also needs to be changed). Naming things is often the hardest part of this stuff...
Configure build target folders in aurelia.json that builds multiple, complete distribution folders.
Changes:
- complete build is made into target root folder based on env (default: build/dev)
- source files in src are never touched
- source file environment.js/ts is never copied into src
- files index.html and favicon.ico should always be in root directory
- build command have a new --target flag
aurelia.json:
- build.targets changed from array to object with target names as keys
- target object in build.targets has the following properties:
+ platform (string): Specifies platform (currently web or aspdotnet)
+ displayName (string): Friendly target name
+ root (string): Target root, relative to project root, default: 'dist/${TARGET}/${ENV}'
+ index (string): Name of target index file, default: 'index.html'
+ output (string): Target folder for bundles, relative to target root, default: 'scripts' (leave it alone)
+ indexSource (string): Name of source index file for target, default: uses target's "index" property (above)
+ resources (array): Unbundled resources copied from project root to target root, default:
[
'favicon.ico',
'scripts/**', // This folder isn't used by the bundles anymore, so these are any additional, non-bundled scripts
'images/**',
'styles/**'
],
+ environments (object): Used to override target settings for environment (dev/stage/prod), default: {}
- build.defaultTarget added that specifies default target when no --target flag is specified
- build.defaultEnvironment added that specifies default environment when no --env flag is specified
Replaces PR aurelia#644.
Closes aurelia#200, aurelia#442, aurelia#563, aurelia#627 and aurelia#677.
Partially closes aurelia#763 and aurelia#724.
a9f2f84 to
41e13fd
Compare
|
Ping @JeroenVinke to review. |
|
I'm highly interested in this feature and I want it released! :) |
JeroenVinke
left a comment
There was a problem hiding this comment.
Awesome, nice work man! I have added a few comments here and there.
I created a typescript project on Windows and it seems to run nicely.
I think we should add documentation for this. Specifically the options in aurelia.json, some sample configurations etc. I'd like to hear your thoughts on that
| } | ||
| }) | ||
| .catch(e => { | ||
| logger.error(`Unable to write the bundle to ${path.posix.join(platform.output, bundleFileName)}`); |
There was a problem hiding this comment.
is there a specific reason for avoiding the logger abstraction here? My idea was to log everything through the logger abstraction so that we can at some point display error messages in red easily
| "aurelia-tools": "^0.2.4", | ||
| "babel-eslint": "^7.1.1", | ||
| "gulp": "^3.9.1", | ||
| "gulp": "git+https://[email protected]/gulpjs/gulp.git#4.0", |
There was a problem hiding this comment.
Do we need these new dependencies (gulp, typescript, babel-polyfill and babel-register)? I think they may have been added when you linked the aurelia-cli using NPM
| throw e; | ||
| }); | ||
| .catch(e => { | ||
| console.log(`Unable to analyze ${(dependency.name || dependency)}`); |
There was a problem hiding this comment.
could you check if the linter is OK with this (gulp lint from the project directory)?
|
|
||
| vfs.src(pattern).pipe(mapStream(copy)) | ||
| .on('error', e => { | ||
| console.log(`Error while copying all matching resources of pattern "${pattern}": ${e.message}`); |
| } | ||
| else { | ||
| if (!targets[targetId]) { | ||
| console.log(`No target "${targetId}" found in configuration!`); |
There was a problem hiding this comment.
should we continue at this point, or should we throw?
| } | ||
|
|
||
| let config = { | ||
| platform: target.id, // Not really necessary for building yet, but is good form (and will be useful) |
There was a problem hiding this comment.
I think we should document these options in the docs
| let dts = gulp.src(project.transpiler.dtsSource); | ||
|
|
||
| let src = gulp.src(project.transpiler.source) | ||
| let src = gulp.src(`aurelia_project/environments/${env}.ts`) |
There was a problem hiding this comment.
While the typescript/babel compiler might be OK with this, isn't the editor going to complain that the environment.js/ts file doesn't exist?
| }); | ||
| }; | ||
|
|
||
| exports.mkdirSync = function (path) { |
There was a problem hiding this comment.
does this create a folder structure if necessary? Nice
There was a problem hiding this comment.
also, have you tested this on linux as well? If not I can do that
| let arr = path.split(/[\\\/]/); | ||
| let folder = arr.shift(); | ||
| if (folder.indexOf(':') !== -1) { | ||
| folder += '/'; |
There was a problem hiding this comment.
could you add some comments here?
|
Any progress on this? I'd like to see this feature. |
|
@JeroenVinke |
|
@Jenselme @avrahamcool the comments (and merge conflicts) have to be addressed until it can be merged. Since this is quite a big change, we need to thoroughly test it as well. @avrahamcool if someone can create a separate PR for that I can get it into the next release. I'm going to try and do releases more often from now on |
|
I'll try and take a look at comments and merge conflicts this weekend. |
|
Closed the stale PR. Please reopen when it's needed. |
Configure build target folders in aurelia.json that builds multiple, complete distribution folders.
Changes:
aurelia.json:
[
'favicon.ico',
'scripts/', // This folder isn't used by the bundles anymore, so these are any additional, non-bundled scripts
'images/',
'styles/**'
],
Replaces PR #644.
Closes #200, #442, #563, #627 and #677.
Partially closes #763 and #724.