@nativescript-community/xml-ui-loader
这是一个 webpack loader,作为编译器在构建阶段将 XML 内容转换为 JavaScript。
npm i --save @nativescript-community/xml-ui-loader
- 版本:3.3.1-alpha.3
- GitHub:
- NPM: https://npmjs.net.cn/package/%40nativescript-community%2Fxml-ui-loader
- 下载
- 昨日: 0
- 上周: 2
- 上月: 205
@nativescript-community/xml-ui-loader
此 loader 为在 Webpack 中使用 @nativescript-community/xml-ui-compiler 提供支持。
安装
npm install @nativescript-community/xml-ui-loader --save-dev
用法
webpack.config.js
const webpack = require('@nativescript/webpack');
const { getEntryDirPath, getPlatformName } = require('@nativescript/webpack/dist/helpers/platform');
const { chainLoaderConfiguration } = require("@nativescript-community/xml-ui-loader/helpers");
module.exports = (env) => {
webpack.init(env);
// Learn how to customize:
// https://docs.nativescript.cn/webpack
webpack.chainWebpack((config) => {
chainLoaderConfiguration(config, {
appPath: getEntryDirPath(),
platform: getPlatformName()
});
});
return webpack.resolveConfig();
};
还有一些预处理选项,对于应用输出自定义很有用。
chainLoaderConfiguration(config, {
appPath: getEntryDirPath(),
platform: getPlatformName(),
useDataBinding: false, // Set this to false if you don't want to use data binding system
preprocess: {
// Format attribute value
attributeValueFormatter: (value, attributeName, tagName, attributes) => value.toUpperCase(),
// Manage AST result
transformAst: (ast, generateFunc) => generateFunc(ast).code,
}
});