Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't minify ionic project

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

like image 736
alfredopacino Avatar asked Mar 13 '18 23:03

alfredopacino


1 Answers

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.

like image 87
alfredopacino Avatar answered Nov 08 '22 09:11

alfredopacino