不能缩小离子项目

时间:2018-03-13 23:33:09

标签: cordova ionic-framework

在我运行

之后,我尝试cordova-uglifylink)缩小Ionic1项目
ionic cordova build --release

我在www的{​​{1}}文件夹中看到我的js源代码..根本没有缩小。

app-release-unsigned.apk打印:

ionic info

编辑:我注意到当我运行[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 时,我收到了这些错误:

ionic cordova build --release

我没有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' 文件夹

@Antonis这些是我尝试的步骤:

  • 我删除了node_modules并重新安装了.\platforms\android\assets\www
  • 我试过npm install
  • 删除并重新添加Android平台npm rebuild node-sass --force
  • 仍然会收到错误ionic cordova build --release

如何生成ENOENT: no such file or directory, scandir C:\nodejs\myproject\platforms\android\assets\www\js [...]文件夹? 我看到assets中有资产文件夹,但模块离子缩小搜索.\platforms\android\app\src\main\assets

3 个答案:

答案 0 :(得分:3)

我注意到platforms\android\app\src\main\assets中有一个资源文件夹,所以我编辑了.\hooks\after_prepare\uglify.js.\hooks\after_prepare\010_add_platform_class.js匹配该路径。看起来它现在有效。

答案 1 :(得分:0)

请为离子项目尝试此minify节点模块。

https://github.com/Jiansen/ionic-minify

答案 2 :(得分:0)

您只需要修改hooks/uglify-config.json。默认情况下,有一个条目显示为:

"foldersToProcess": [
    "platforms/browser/www"
],

将其更改为空字符串:

"foldersToProcess": [
    ""
],