Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get the minified version of ionic-native? #72

Closed
suwarno-ong opened this issue Mar 18, 2016 · 9 comments
Closed

How can I get the minified version of ionic-native? #72

suwarno-ong opened this issue Mar 18, 2016 · 9 comments
Labels

Comments

@suwarno-ong
Copy link

Sorry noob question here. Anyone knows how to get the minified javascript version of the ionic-native?

@ihadeed
Copy link
Collaborator

ihadeed commented Mar 18, 2016

I don't see any minified JS in the package. I'm afraid you would have to minify it yourself for now.

@suwarno-ong
Copy link
Author

Yes, I try to self-help using gulp.

var typescript = require('gulp-tsc');
var concatJs = require('gulp-concat');
var uglifyJs = require('gulp-uglify');
var rename = require('gulp-rename');

var paths = {
  typescript: ['src/**/*.ts'],
};

gulp.task('compile', function(done) {
  gulp.src(paths.typescript)
    .pipe(typescript({ emitError: false }))
    .pipe(concatJs('ionic-native.js'))
    .pipe(gulp.dest('dist'))
    .pipe(uglifyJs())
    .pipe(rename({ extname: '.min.js' }))
    .pipe(gulp.dest('dist'))
    .on('end', done);
});

Perhaps there is a sequence requirement when concatenating the ts file.
I hit errors like require is not defined, so I try to add require.js
Then i hit Module name "ng1" has not been loaded yet for context: _. Use require([])

Anyone can share how you concat and minify ionic-native to a single js file?

@ihadeed
Copy link
Collaborator

ihadeed commented Mar 18, 2016

@deepslux are you using Ionic 2?

If so, you do not need to import any JS files to your index.html. You also wouldn't need to minify anything.

Importing the plugin you need in your TypeScript files (import {Camera} from 'ionic-native';) will result in the needed code to be compiled in your app bundle JS file.

@suwarno-ong
Copy link
Author

@ihadeed I'm using Ionic 1. Is this repo meant for Ionic 2? Or anything I need to do to use it in Ionic 1?

@ihadeed
Copy link
Collaborator

ihadeed commented Mar 19, 2016

@deepslux I haven't tested it personally. But looking at the code it looks like the Angular 1 usage would be by importing the ngCordova module in your main app module. Then calling methods like ngCordova.Camera.getPicture().then(....

The methods are also exposed in the variable window.IonicNative.

I wrote a little article explaining the various way of using Ionic Native, but again I haven't really tested it. Hence, why I haven't officially published the article. But you can have a look here: http://jsdev.ca/ionic-native-cordova-plugins-simplified/

@ihadeed ihadeed closed this as completed Mar 24, 2016
@seeps001
Copy link

@deepslux did you manage to get ionic-native working with Ionic 1? I'm having issues setting things update. I've installed ionic-native, but now need to include ionic.native.js in my index.html, but having issues with the path.

@seeps001
Copy link

@ihadeed Could you please assist, how should ionic-native be included in index.html. I'm having issues with referencing the correct path to ionic.native.js. I'm using Ionic 1.

@pabloleone
Copy link

This issue shouldn't be closed! It is not clear how to import the library when working with AngularJS 1.x

ngCordova (last reply) is not a valid answer as it doesn't exist anymore.

The import keyword in the JS files is not supported and there's no native import. We need to know which files to include in the index.html and the order they should be added.

Thank you.

@ihadeed
Copy link
Collaborator

ihadeed commented Apr 13, 2019

@pabloleone

Please open a new issue with any questions that you have.

Currently there is no ES5 files exported in the Ionic Native package. It is still compatible with AngularJS 1.x but you need something to transform it from ES2015 to ES5 (Babel, Webpack, Rollup...etc).

ngCordova doesn't exist anymore, we export it under the ionic.native module. See https://unpkg.com/@ionic-native/core@5.4.0/ng1.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants