Commit
…tml into app/
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,147 @@ | ||
/* global require, module */ | ||
|
||
var uglifyJavaScript = require('broccoli-uglify-js'); | ||
var replace = require('broccoli-replace'); | ||
var compileES6 = require('broccoli-es6-concatenator'); | ||
var p = require('ember-cli/lib/preprocessors'); | ||
var pickFiles = require('broccoli-static-compiler'); | ||
var env = require('broccoli-env').getEnv(); | ||
|
||
var p = require('ember-cli/lib/preprocessors'); | ||
var preprocessCss = p.preprocessCss; | ||
var preprocessTemplates = p.preprocessTemplates; | ||
var preprocessJs = p.preprocessJs; | ||
|
||
module.exports = function (broccoli) { | ||
var app = 'app'; | ||
var tests = 'tests'; | ||
var publicFiles = 'public'; | ||
var vendor = 'vendor'; | ||
var config = 'config'; | ||
var styles; | ||
var qunit; | ||
var testsIndex; | ||
|
||
app = pickFiles(app, { | ||
srcDir: '/', | ||
destDir: '<%= modulePrefix %>/' | ||
}); | ||
|
||
app = preprocessTemplates(app); | ||
var prefix = '<%= modulePrefix %>'; | ||
var rootURL = '/'; | ||
|
||
|
||
config = pickFiles(config, { | ||
// index.html | ||
|
||
var indexHTML = pickFiles('app', { | ||
srcDir: '/', | ||
files: [ | ||
'environment.*', | ||
'environments/' + env + '.*' | ||
], | ||
destDir: '<%= modulePrefix %>/config' | ||
files: ['index.html'], | ||
destDir: '/' | ||
}); | ||
|
||
indexHTML = replace(indexHTML, { | ||
files: ['index.html'], | ||
patterns: [{ match: /\{\{rootURL\}\}/g, replacement: rootURL}] | ||
}); | ||
|
||
testsIndex = pickFiles(tests, { | ||
var testsIndexHTML = pickFiles('tests', { | ||
srcDir: '/', | ||
files: ['index.html'], | ||
destDir: '/tests' | ||
}); | ||
|
||
tests = pickFiles(tests, { | ||
testsIndexHTML = replace(testsIndexHTML, { | ||
files: ['tests/index.html'], | ||
patterns: [{ match: /\{\{rootURL\}\}/g, replacement: rootURL}] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
MajorBreakfast
Author
Contributor
|
||
}); | ||
|
||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
// sourceTrees, appAndDependencies for CSS and JavaScript | ||
|
||
var app = pickFiles('app', { | ||
srcDir: '/', | ||
destDir: '<%= modulePrefix %>/tests' | ||
destDir: prefix | ||
}); | ||
|
||
qunit = pickFiles(vendor, { | ||
srcDir: '/qunit/qunit', | ||
files: ['qunit.css'], | ||
destDir: '/assets/' | ||
app = preprocessTemplates(app); | ||
|
||
var config = pickFiles('config', { | ||
srcDir: '/', | ||
files: [ | ||
'environment.*', | ||
'environments/' + env + '.*' | ||
], | ||
destDir: prefix + '/config' | ||
}); | ||
|
||
tests = preprocessTemplates(tests); | ||
var sourceTrees = [app, config, 'vendor'].concat(broccoli.bowerTrees()); | ||
|
||
var sourceTrees = [ | ||
app, | ||
config, | ||
vendor | ||
]; | ||
if (env !== 'production') { | ||
var tests = pickFiles('tests', { | ||
srcDir: '/', | ||
destDir: prefix + '/tests' | ||
}); | ||
|
||
tests = preprocessTemplates(tests); | ||
sourceTrees.push(tests); | ||
} | ||
|
||
var appAndDependencies = new broccoli.MergedTree(sourceTrees); | ||
|
||
|
||
// JavaScript | ||
|
||
var legacyFilesToAppend = [ | ||
'<%= modulePrefix %>/config/environment.js', | ||
'<%= modulePrefix %>/config/environments/' + env + '.js', | ||
prefix + '/config/environment.js', | ||
prefix + '/config/environments/' + env + '.js', | ||
'jquery.js', | ||
'handlebars.js', | ||
'ember.js', | ||
'ic-ajax/main.js', | ||
'ember-data.js', | ||
'ember-resolver.js' | ||
'ember-resolver.js', | ||
'ember-shim.js' | ||
]; | ||
|
||
if (env !== 'production') { | ||
legacyFilesToAppend.push( | ||
'ember-shim.js', | ||
'qunit/qunit/qunit.js', | ||
'qunit-shim.js', | ||
'ember-qunit/dist/named-amd/main.js' | ||
); | ||
|
||
sourceTrees.push(tests); | ||
} | ||
|
||
sourceTrees = sourceTrees.concat(broccoli.bowerTrees()); | ||
|
||
var appAndDependencies = new broccoli.MergedTree(sourceTrees); | ||
var applicationJs = preprocessJs(appAndDependencies, '/', prefix); | ||
|
||
appAndDependencies = preprocessJs(appAndDependencies, '/', '<%= modulePrefix %>'); | ||
|
||
var applicationJs = compileES6(appAndDependencies, { | ||
applicationJs = compileES6(applicationJs, { | ||
loaderFile: 'loader/loader.js', | ||
ignoredModules: [ | ||
'ember/resolver', | ||
'ember-qunit' | ||
], | ||
inputFiles: [ | ||
'<%= modulePrefix %>/**/*.js' | ||
prefix + '/**/*.js' | ||
], | ||
legacyFilesToAppend: legacyFilesToAppend, | ||
|
||
wrapInEval: env !== 'production', | ||
outputFile: '/assets/app.js' | ||
}); | ||
|
||
styles = preprocessCss(sourceTrees, '<%= modulePrefix %>/styles', '/assets'); | ||
|
||
if (env === 'production') { | ||
applicationJs = uglifyJavaScript(applicationJs, { | ||
mangle: false, | ||
compress: false | ||
}); | ||
} | ||
|
||
var outputTrees = [ | ||
applicationJs, | ||
publicFiles, | ||
styles | ||
]; | ||
|
||
// Styles | ||
|
||
styles = preprocessCss(sourceTrees, prefix + '/styles', '/assets'); | ||
|
||
qunitStyles = pickFiles('vendor', { | ||
srcDir: '/qunit/qunit', | ||
files: ['qunit.css'], | ||
destDir: '/assets/' | ||
}); | ||
|
||
|
||
// Ouput | ||
|
||
var outputTrees = [indexHTML, applicationJs, 'public', styles]; | ||
|
||
if (env !== 'production') { | ||
outputTrees.push(qunit, testsIndex); | ||
outputTrees.push(qunitStyles, testsIndexHTML); | ||
} | ||
|
||
|
||
return outputTrees; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ | |
<meta name='description' content=''> | ||
<meta name='viewport' content='width=device-width, initial-scale=1'> | ||
|
||
<script> // Sets base tag in order to support history location properly | ||
document.write('<base href="' + document.location.origin + '{{rootURL}}" />'); | ||
This comment has been minimized.
Sorry, something went wrong.
stefanpenner
Contributor
|
||
</script> | ||
|
||
<link rel='stylesheet' href='/assets/app.css'> | ||
<script src='/assets/app.js'></script> | ||
</head> | ||
|
5 comments
on commit 4040914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MajorBreakfast something worth for the CHANGELOG?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. This issue gives detailed information on what the current status is: #172
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MajorBreakfast in general i would prefer to have these code-reviews in PR's not on a commit on master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize we're not 1.0 yet, but how careful should we be when moving files around in the blueprint? We'll need to communicate to users when to rerun ember init
in their apps to upgrade, and what files they can safely remove. Or should we remove them in init automatically? @MajorBreakfast @stefanpenner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joefiorini I don't think we can remove, but likely a good change-log is appropriate.
We should not move any files around in blueprint without a PR and some discussion.
good for now, but we should prefer a better templating solution re: handlebars/mustache