forked from ember-cli/ember-twiddle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathember-cli-build.js
108 lines (94 loc) · 3.89 KB
/
ember-cli-build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* global require, module, process */
module.exports = function() {
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var funnel = require('broccoli-funnel');
var concat = require('broccoli-concat');
var mergeTrees = require('broccoli-merge-trees');
var pickFiles = require('broccoli-static-compiler');
var env = EmberApp.env();
var isProductionLikeBuild = ['production', 'staging'].indexOf(env) > -1;
var prepend = null;
if(isProductionLikeBuild) {
prepend = env==='production' ? '//assets.ember-twiddle.com/' : '//canary-assets.ember-twiddle.com/';
}
var blueprintsCode = getEmberCLIBlueprints();
var app = new EmberApp({
fingerprint: {
enabled: isProductionLikeBuild,
prepend: prepend
},
codemirror: {
modes: ['xml', 'javascript', 'handlebars', 'htmlmixed', 'css'],
keyMaps: ['emacs', 'sublime', 'vim']
},
'ember-cli-bootstrap-sassy': {
'js': ['dropdown']
},
fileCreator: [{filename: '/lib/blueprints.js', content: blueprintsCode}],
sourcemaps: {
enabled: !isProductionLikeBuild,
},
minifyCSS: { enabled: isProductionLikeBuild },
minifyJS: { enabled: isProductionLikeBuild },
tests: process.env.EMBER_CLI_TEST_COMMAND || !isProductionLikeBuild,
hinting: process.env.EMBER_CLI_TEST_COMMAND || !isProductionLikeBuild,
vendorFiles: {
'ember.js': {
staging: 'bower_components/ember/ember.prod.js'
}
}
});
app.import('bower_components/ember/ember-template-compiler.js');
app.import('vendor/hint.css');
app.import('vendor/drags.js');
var twiddlicons = pickFiles('vendor/twiddlicon/',{
srcDir: '/',
include: ['**/*.woff', '**/*.eot', '**/*.ttf', '**/*.svg'],
destDir: '/assets'
});
var loaderTree = pickFiles('bower_components', {
srcDir: '/loader.js',
files: ['loader.js'],
destDir: '/assets'
});
var twiddleVendorTree = concat(funnel('bower_components'),{
inputFiles: [
'loader.js/loader.js',
'ember-resolver/dist/modules/ember-resolver.js',
'ember-cli-shims/app-shims.js',
'ember-load-initializers/ember-load-initializers.js',
],
outputFile: '/assets/twiddle-deps.js',
});
return mergeTrees([app.toTree(), twiddleVendorTree, loaderTree, twiddlicons]);
};
// This copies code out of ember-cli's blueprints into
// app/lib/blueprints so we don't have to maintain our
// own blueprints
function getEmberCLIBlueprints() {
var fs = require('fs');
var fileMap = {};
var cliPath = 'node_modules/ember-cli';
var cliBlueprintFiles = {
'app': 'app/files/app/app.js',
'router': 'app/files/app/router.js',
'component-js': 'component/files/__root__/__path__/__name__.js',
'component-hbs': 'component/files/__root__/__templatepath__/__templatename__.hbs',
'model': 'model/files/__root__/__path__/__name__.js',
'route': 'route/files/__root__/__path__/__name__.js',
'controller': 'controller/files/__root__/__path__/__name__.js',
'template': 'template/files/__root__/__path__/__name__.hbs',
};
for (var blueprintName in cliBlueprintFiles) {
var filePath = cliPath + '/blueprints/' + cliBlueprintFiles[blueprintName];
fileMap[blueprintName] = fs.readFileSync(filePath).toString();
}
fileMap['twiddle.json'] = fs.readFileSync('blueprints/twiddle.json').toString();
fileMap['initializers/router'] = fs.readFileSync('blueprints/router_initializer.js').toString();
fileMap['initializers/mouse-events'] = fs.readFileSync('blueprints/mouse_events_initializer.js').toString();
fileMap['controllers/application'] = fs.readFileSync('blueprints/application_controller.js').toString();
fileMap['templates/application'] = fs.readFileSync('blueprints/application_template.hbs').toString();
fileMap['app.css'] = fs.readFileSync('blueprints/app.css').toString();
fileMap['index.html'] = fs.readFileSync('blueprints/index.html').toString();
return 'export default ' + JSON.stringify(fileMap);
}