在我运行
之后,我尝试cordova-uglify
(link)缩小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这些是我尝试的步骤:
.\platforms\android\assets\www
npm install
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
答案 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": [
""
],