I tried cordova-uglify
(link) to minify a Ionic1 project, after I run
ionic cordova build --release
I see my js source code in www
folder of app-release-unsigned.apk
.. is not minified at all.
ionic info
prints:
[WARN] Error with .\www\lib\ionic\version.json file: FILE_NOT_FOUND, trying .\bower.json. cli packages: (C:\Program Files\nodejs\node_modules) @ionic/cli-utils : 1.19.1 ionic (Ionic CLI) : 3.19.1 global packages: cordova (Cordova CLI) : 8.0.0 Gulp CLI : not installed globally local packages: Cordova Platforms : android 7.0.0 ios 4.5.4 Ionic Framework : ionic1 1.3.4 System: Android SDK Tools : 26.0.1 Node : v8.9.4 npm : 5.6.0 OS : Windows 7
Edit: I noticed when I run ionic cordova build --release
I get those errors:
An error ocurred while reading directories: Error: ENOENT: no such file or directory, scandir 'C:\nodejs\myproject\platforms\android\assets\www\js' An error ocurred while reading directories: Error: ENOENT: no such file or directory, scandir 'C:\nodejs\myproject\platforms\android\assets\www\css' An error ocurred while reading directories: Error: ENOENT: no such file or directory, scandir 'C:\nodejs\myproject\platforms\android\assets\www\img' Running command: "C:\Program Files\nodejs\node.exe" C:\nodejs\myproject\hooks\after_prepare\uglify.js C:\nodejs\myproject processFiles err: Error: ENOENT: no such file or directory, scandir 'C:\nodejs\myproject\platforms\android\assets\www\js' processFiles err: Error: ENOENT: no such file or directory, scandir 'C:\nodejs\myproject\platforms\android\assets\www\css' processFiles err: Error: ENOENT: no such file or directory, scandir 'C:\nodejs\myproject\platforms\android\assets\www\img' processFiles err: Error: ENOENT: no such file or directory, scandir 'C:\nodejs\myproject\platforms\android\assets\www\build'
I do not have a .\platforms\android\assets\www
folder
@Antonis Those are the steps I tried:
- I deleted node_modules and reinstalled
npm install
- I tried
npm rebuild node-sass --force
- remove and re-add android platform
ionic cordova build --release
- still get the errors
ENOENT: no such file or directory, scandir C:\nodejs\myproject\platforms\android\assets\www\js [...]
How can I generate that assets
folder? I see there is an assets folder in .\platforms\android\app\src\main\assets
but the module ionic-minify search for .\platforms\android\assets
2 Answers
Answers 1
I noticed I have an assets folder in platforms\android\app\src\main\assets
so I edited .\hooks\after_prepare\uglify.js
and .\hooks\after_prepare\010_add_platform_class.js
to match that path. It looks like it works now.
Answers 2
Please try this minify node module for your ionic project.
https://github.com/Jiansen/ionic-minify
0 comments:
Post a Comment