How can extend the ember-cli build? - ember.js

I want to have some custom steps run during them ember cli build, is there a supported way to do that? Specifically, I want to parse comments in css files and build write files to the public directory based on those comments.

You should create an ember-cli addon to create extra build steps. There is some good documentation around on Google, but here is a blog post I used to create addons. This guide is more tailored toward creating ember components but there are other ember-cli hooks you could use to run code during the build process.
Perhaps you could use the included hook to run some code to read your css files and then import your files into the public directory. Other hooks that you could use are documented here
Alternatively, if there is a broccoli plugin that does what you want, you simply need to add it to your package.json and run npm install. Now the plugin has been added to the build system.

Related

Install an NPM package without its optional modules in Ember-CLI

I've got the NPM package xlsx as a dependency in my ember app which comes with an optional module for translations. When I build my app with Ember-CLI I'd like to specify somehow that this optional module be excluded.
The README for that package states “Webpack and browserify builds include optional modules by default. Webpack can be configured to remove support with resolve.alias:”
I'm not sure how I could configure my ember-cli-build.js to work with this.
I do know that I can download the package, build it myself, and then stick the resulting files in my vendor directory but this feels like the wrong way to go about it.
Does anybody have experience with this sort of situation?
Edit
I'm currently including xlsx in my app as a dependency inside my package.json and simply importing it within one of my components.
If you take a look into your node_modules/xlsx/dist/ folder you'll see that there are several different versions of xlsx available: core, full and a third version without a specifier.
You can use either of those versions by putting for example
app.import('node_modules/xlsx/dist/xlsx.core.min.js');
in your ember-cli-build.js file.
Note that the above requires Ember CLI 2.15 or above. If you use an older Ember CLI version you should either upgrade or install xlsx from Bower instead.

Can I specify Git URLs as dependencies in Buck?

I am using Buck to build a C++ project.
I would like to add a Git URL (e.g. git#github.com:owner/project.git) as a dependency so that a build can automatically pull down a library from GitHub. I took a look at remote_file, but that only seems to work for HTTP, HTTPS and Maven.
Does Buck provide this functionality out-of-the-box?
If so, is it possible to specify a specific commit hash or tag?
Buck does not support remote Git URLs.
Your options are:
Copy the code manually into your project
Use an equivalent .zip URL (GitHub gives you these)
Use submodules, such as in this example
Use a package manager that supports Buck, such as Buckaroo

Is the ember cli addon installation broken in Ember Cli 0.1.11?

I'm using ember cli for some small test projects to evaluate the concepts. Normal use of ember cli works for me. After 10 created small projects and using blueprints and the pod structure I decided to try the development and usage of addons. The creation of addons was not the real problem.
The problem is I can not successfully install a created addon. I also tried to install other addons created by other ember-cli users. The result is always the same. I got no error message and the addon could be found inside the node_modules directory of the addon consuming application but there is nothing installed in the app directory and it's sub directories !!!
What can I do to find the problem ?
Do you have a public available addon which could be installed definitely without problems ?
Are there log files which could be inspected to see more details (hidden error messages) ?
Best regads
Andreas
The current Ember CLI version is 0.0.12. I'm not aware of any issues with addon installations. If the issue persist, you should create an issue on ember-cli issue tracker.

Exclude files while using Ember-CLI testem

I am trying to run my tests using Ember-CLI - Testem.
Ember-CLI uses tests/index.html and not the usual testem.json config for testing.
Is there any way I can exclude certain files from being built into app.js?
Usecase : I have some js files where I inject some dependencies. These dependencies are different during the testing environment. I would like to ignore these files and inject the dependencies from my test-injectors.
I'm answering in the context of an ember application using ember-cli 1.13.8 and ember 2.1.
ember-cli does use testem.json unless you pass another test configuration file via ember test -c path/to/testem.json. Though, not all options from testem.json are integrated into ember-cli's test process.
To exclude trees, checkout:
ember-cli exclude a directory beneath "tests" from being watched by "ember serve"
For ignoring specific files in tests, you can rename files so that they do not match the pattern embedded into ember-cli-test-loader:
https://github.com/ember-cli/ember-cli-test-loader/blob/master/test-loader.js#L38-L40

Eliminate unnecessary Bower files in production

I have a Django app running on Heroku that uses Bower to manage front-end dependencies. These dependencies, along with my application, are optimized with RequireJS and served up using Amazon S3. Is there an easy way for me to know what files in my bower_components directory can be safely deleted from my static file server?
I would leave your bower_components folder in your root, untouched and ignored by your VCS. Then use something like Grunt to copy the selected files into a scripts folder somewhere and then use RequireJS to build those.
This allows you to easily update your bower components and prevents you needing to commit needless repository cruft into your repo.
You can use the Grunt concat or copy task to do this or try the grunt-bowercopy task that will also run a bower install for you
The best solution I have found so far is to use django-pipeline to process front-end assets. django-pipeline will:
...help you by excluding much of the extra content that Bower includes
with its components, such as READMEs, tests and examples, while still
including images, fonts, CSS fragments etc.
(from Using Pipeline with Bower)