How can i add a library(bower or npm package) to ember-cli-mirage

How can i add a library to config.js file into mirage folder ?

I’ve been trying to add a library to ember cli mirage to transform some data

//mirage/config.js

import LIBRARY from "./../node_modules/My_npm_package";

export default function() {

...

it never find the library, and i also tried with something like this

var library = require('library');

i must be missing something but the thing is, i don’t want to touch the addon itself to make it work.

I believe you’ll need to pull in dependencies the same way you would in your core app code. Is this library available in Bower? If so, install with Bower and in your ember-cli-build.js place an “app.import” statement.

ember-cli-build.js app.import('./bower_components/moment/min/moment.min.js')

/mirage/config.js moment().format('dddd')

If the library in question is not available in Bower, you can always manually place it in your vendor directory and import the same way.

1 Like