当前位置: 动力学知识库 > 问答 > 编程问答 >

ionic framework - Change cordova www location

问题描述:

I'm using a script which is being ran before_prepare. The script lints, annotates, minifies, concatenates, creates templates cache for any html template, etc in a cordova - ionic app.

This script is placing all output in a www-build folder, sibbling to www (but it can be placed wherever is needed):

├── www

│ ├── css

│ │ └── style.css

│ ├── img

│ │ └── logo.png

│ ├── index.html

│ ├── js

│ │ ├── app.js

│ │ ├── audit

│ │ └── tabs

│ ├── lib

│ │ └── ionic

│ ├── manifest.json

│ └── service-worker.js

└── www-build

├── all.min.css

├── all.min.js

├── img

│ └── logo.png

├── index.html

├── lib

│ └── ionic

└── manifest.json

I'm wondering if there is a way to tell cordova to use this new www-build folder at runtime (during cordova prepare) to get all files to copy to platform assets.

Maybe if its not at runtime, is there any static way?

Right now I'm hooking after_prepare and deleting the assets cordova prepared and copying the new ones to each platform, but I'm wondering if this is a good practice.

网友答案:

Cordova looks in /www by default. I don't think this can be changed. Why not just have all your source code in a new directory /src and then have your built code placed in /www?

├── src
│   ├── css
│   │   └── style.css
│   ├── img
│   │   └── logo.png
│   ├── index.html
│   ├── js
│   │   ├── app.js
│   │   ├── audit
│   │   └── tabs
│   ├── lib
│   │   └── ionic
│   ├── manifest.json
│   └── service-worker.js
└── www
    ├── all.min.css
    ├── all.min.js
    ├── img
    │   └── logo.png
    ├── index.html
    ├── lib
    │   └── ionic
    └── manifest.json
网友答案:

Following the idea of @johnborges response My solution has been to make the script do the following steps:

Before prepare:

  • Move www/ to src/
  • Process src/ to www/ (lint, compress, concat, annotate, etc.)

After prepare:

  • Delete www/
  • Move src/ back to www/

In this way the scripts copied to platform are the processed ones, and it does work with phonegap serve.

分享给朋友:
您可能感兴趣的文章:
随机阅读: