How to import module ember-localstorage-adapter with Ember-CLI?
UPDATE
ember-localstorage-adapter is now an ember-cli addon, so to add it to asset pipeline just run:
ember install ember-localstorage-adapter
for latest ember-cli versions (after 1.5)
or
npm install --save-dev ember-localstorage-adapter
for versions before 1.5
And go to step 4, to configure the adapter and serializer.
If you're using an old version of ember-cli, please use the steps below:
I did the following steps to import the ember-localstorage-adapter:
1- Created a new ember application with:
ember new <someapp>
2- Installed the ember-localstorage-adapter dependency with bower:
bower install ember-localstorage-adapter --save
3- Added the app.import("bower_components/ember-localstorage-adapter/localstorage_adapter.js");
before the module.exports = app.toTree();
call inside of Brocfile.js
This is the entire Brocfile.js:
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp();
app.import("bower_components/ember-localstorage-adapter/localstorage_adapter.js");
module.exports = app.toTree();
4- Used the DS.LSAdapter
as the default adapter creating a file called app/adapters/application.js
with the following content:
import DS from 'ember-data';
export default DS.LSAdapter.extend({
namespace: 'yournamespace'
});
5- Used the DS.LSSerializer
as the default serializer creating a file called app/serializers/application.js
with the following content:
import DS from 'ember-data';
export default DS.LSSerializer.extend();
I hope it helps