Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ionic 3在构建时更改变量/主题_Javascript_Ionic Framework_Sass - Fatal编程技术网

Javascript Ionic 3在构建时更改变量/主题

Javascript Ionic 3在构建时更改变量/主题,javascript,ionic-framework,sass,Javascript,Ionic Framework,Sass,我需要在爱奥尼亚3中创建2个主题。 实际上,我只需要两个版本的variables.scss文件 一个将有一个托盘的颜色,另一个相同的变量,但不同的颜色 有没有可能在构建时说ionic要使用哪个主题(variables.scs),或者在构建时以某种方式更改颜色托盘?我用ionic构建挂钩解决了这个问题 参考: 在文件夹“\src\theme”中,我为每个主题创建了一个文件夹。文件夹只包含variable.scss文件和我需要的调色板 在ionic.config.json中,我根据文档添加了挂钩

我需要在爱奥尼亚3中创建2个主题。 实际上,我只需要两个版本的variables.scss文件

一个将有一个托盘的颜色,另一个相同的变量,但不同的颜色


有没有可能在构建时说ionic要使用哪个主题(variables.scs),或者在构建时以某种方式更改颜色托盘?

我用ionic构建挂钩解决了这个问题

参考:

在文件夹“\src\theme”中,我为每个主题创建了一个文件夹。文件夹只包含variable.scss文件和我需要的调色板

在ionic.config.json中,我根据文档添加了挂钩:

"hooks": {
    "serve:before": "./scripts/serve-build-before.js",
    "build:before": "./scripts/serve-build-before.js"
 }
我创建了文件夹脚本并添加了serve-build-before.js文件,该文件将在每次构建过程启动时调用:

module.exports = function(context) {
    const fs = require('fs');

    if (context && context.argv) {
        let theme;
        for (let i = 0; i < context.argv.length; i++) {
            let argument = context.argv[i]; 
            if (argument.indexOf('theme.') > -1) {
                theme = argument;
                break
            }   
        }

        theme = (theme) ? theme: 'theme.defaultTheme'; // default theme

        const themeName = theme.split('.')[1];
        fs.copyFileSync('src/theme/' + themeName + '/variables.scss', 'src/theme/variables.scss');
    }

};

我用ionic构建钩子解决了这个问题

参考:

在文件夹“\src\theme”中,我为每个主题创建了一个文件夹。文件夹只包含variable.scss文件和我需要的调色板

在ionic.config.json中,我根据文档添加了挂钩:

"hooks": {
    "serve:before": "./scripts/serve-build-before.js",
    "build:before": "./scripts/serve-build-before.js"
 }
我创建了文件夹脚本并添加了serve-build-before.js文件,该文件将在每次构建过程启动时调用:

module.exports = function(context) {
    const fs = require('fs');

    if (context && context.argv) {
        let theme;
        for (let i = 0; i < context.argv.length; i++) {
            let argument = context.argv[i]; 
            if (argument.indexOf('theme.') > -1) {
                theme = argument;
                break
            }   
        }

        theme = (theme) ? theme: 'theme.defaultTheme'; // default theme

        const themeName = theme.split('.')[1];
        fs.copyFileSync('src/theme/' + themeName + '/variables.scss', 'src/theme/variables.scss');
    }

};

同样适用于离子5.410和离子角4.11.1。我正在寻找一种方法来定制我的主题而不使用环境。环境是dev、test、prepod、prod,而主题是特定客户机的打包(每个客户机都有一个移动应用程序,有自己的主题)。还可以使用Ionic 5.410、Ionic Angular 4.11.1。我正在寻找一种方法来定制我的主题而不使用环境。环境是dev、test、prepod、prod,而主题是特定客户机的打包(每个客户机有一个移动应用程序,有自己的主题)。