I want to add the minify command to use in Ionic 2 project. After reading of this manual https://github.com/driftyco/ionic-app-scripts. I add the needed section to package.json.
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"minify": "ionic-app-scripts minify",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
}
Run npm run minify. And occurs a error:
> MobileSiteApp@ minify D:\denwerready\-readyscript\modules\mobilesiteapp\appsou
rce
> ionic-app-scripts minify
[14:13:05] ionic-app-scripts 1.3.2
[14:13:05] minify started ...
[14:13:05] cleancss started ...
[14:13:05] uglifyjs started ...
[14:13:06] ionic-app-script task: "minify"
[14:13:06] Error: Cannot read property 'filter' of undefined in undefined at li
ne undefined, col undefined, pos
undefined
Error: Cannot read property 'filter' of undefined in undefined at line undefined
, col undefined, pos undefined
at new BuildError (D:\denwerready\-readyscript\modules\mobilesiteapp\appsour
ce\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
at taskReject (D:\denwerready\-readyscript\modules\mobilesiteapp\appsource\n
ode_modules\@ionic\app-scripts\dist\worker-process.js:36:22)
at D:\denwerready\-readyscript\modules\mobilesiteapp\appsource\node_modules\
@ionic\app-scripts\dist\worker-process.js:14:13
at process._tickCallback (internal/process/next_tick.js:109:7)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "run" "minify"
npm ERR! node v7.9.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! MobileSiteApp@ minify: `ionic-app-scripts minify`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the MobileSiteApp@ minify script 'ionic-app-scripts minify'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the MobileSiteApp package
,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts minify
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs MobileSiteApp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls MobileSiteApp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\效褍斜蟹懈泻\AppData\Roaming\npm-cache\_logs\2017-04-26T11_13_06
_136Z-debug.log
How to fix it? I have lastest Ionic v.3 and ionic-app-script v.1.3.2
I don't think it's on our road map to fix this due to app-scripts evolving. Sorry! Best bet is to just use ionic build --prod.
Thanks,
Dan
@danbucholtz For me "npm run build --prod" and "npm run build" works perfectly.
But "npm run minify" shows error: "Error: Cannot read property 'filter' of undefined in undefined at line undefined, col undefined, pos undefined"
P.S.: ionic-app-scripts 1.3.6
For you yes. But in my case I use in templateUrl remote address to get template. And --prod flag not working. :(
Keeps happening.
>> ionic-app-scripts minify
>
> [17:19:55] ionic-app-scripts 2.1.3
> [17:19:55] minify started ...
> [17:19:55] cleancss started ...
> [17:19:55] uglifyjs started ...
> [17:19:56] ionic-app-script task: "minify"
> [17:19:56] Error: Cannot read property 'filter' of undefined in undefined at line undefined, col undefined, pos
> undefined
> Error: Cannot read property 'filter' of undefined in undefined at line undefined, col undefined, pos undefined
Ionic info:
> ionic info
>
> cli packages: (/usr/lib/node_modules)
>
> @ionic/cli-utils : 1.10.2
> ionic (Ionic CLI) : 3.10.3
>
> global packages:
>
> Cordova CLI : 7.0.1
>
> local packages:
>
> @ionic/app-scripts : 2.1.3
> Cordova Platforms : android 6.2.3
> Ionic Framework : ionic-angular 3.6.0
>
> System:
>
> Android SDK Tools : 25.2.5
> Node : v8.4.0
> npm : 5.4.1
> OS : Linux 4.10
If it's not going to be fixed perhaps removing the references to the minify task on the README.md would be somewhat useful to avoid further reports like this. I would be way better though to get some light on how to solve it.
Most helpful comment
@danbucholtz For me "npm run build --prod" and "npm run build" works perfectly.
But "npm run minify" shows error: "Error: Cannot read property 'filter' of undefined in undefined at line undefined, col undefined, pos undefined"
P.S.: ionic-app-scripts 1.3.6