Ext JS 代码包:在包构建中包含 resources/css/*.css

Ext JS Code Package: Include resources/css/*.css in package build

我的 Ext JS 包的 resources/css 目录中有一个 CSS 文件。然而 package-all.csssencha package build.

之后是空的

如何让 Sencha 将 CSS 文件的内容放入 package-all.css?它最终应该被复制到使用该包的应用程序的 all.css 文件中。

您必须将其作为资源添加到 package.json

/**
 * Extra resources to be copied along when build
 */
"resources": [
  "resources/css/app.css",
"resources/images",
"resources/static",
"resources/libs",
  "resources/translations"
],

或者作为 css 文件更好。

/**
 * List of all CSS assets in the right inclusion order.
 * Each item is an object with the following format:
 *      {
 *          "path": "path/to/item.css" // Path to file, if local file it must be relative to this app.json file
 *          "remote": true             // (Optional)
 *                                     // - Defaults to undefined (falsey) to signal a local file which will be copied
 *                                     // - Specify true if this file is a remote file which will not to be copied
 *          "update": "delta"          // (Optional)
 *                                     //  - If not specified, this file will only be loaded once, and
 *                                     //    cached inside localStorage until this value is changed to either one below
 *                                     //  - "delta" to enable over-the-air delta update for this file
 *                                     //  - "full" means full update will be made when this file changes
 *
 *      }
 */
"css": [
{
  "path": "resources/libs/Arcgis v3.11/arcgis311.css",
  "remote": true
},
{
  "path": "resources/css/app.css",
  "remote": true
}
]

您可以直接将其包含在 index.html 中。它在构建中也能正常工作。`

<title>xxxxx</title>

<!-- The line below must be kept intact for Sencha Cmd to build your application -->
<link type='text/css' rel='stylesheet' href='resources/custom/css/my_css.css' />
<link type='text/css' rel='stylesheet' href='resources/fonts/font-awesome-4.3.0/css/font-awesome.css' />
<script id="microloader" type="text/javascript" src="bootstrap.js"></script>

`

受 Tarabass 回答的启发,我在包内的 package.json 中添加了我的 CSS 文件。现在它被应用程序使用。

"css": [{
  path: "resources/css/styles.css"
}],