【问题标题】:Variable as a key for path in GruntJS变量作为 GruntJS 中路径的键
【发布时间】:2015-12-29 20:32:11
【问题描述】:

奇怪的行为,当我尝试在 grunt-contrib-sass 中创建 key 变量,而不是路径。

var sourseScssFolder = 'src/scss/*.scss';
var destCssFile = 'src/packed.css';
sass: {
            dist: {
                options: {
                    style: 'nested'
                },
                files: {
                    // Key don't wanna load from variable
                    destCssFile: sourseScssFolder,
                }
            }
        },

在此编译器创建文件“dest File”之后,改为从 var 读取。如何解决这个问题?

【问题讨论】:

    标签: javascript gruntjs grunt-contrib-sass


    【解决方案1】:

    正在使用 vanilla Javascript 配置 Grunt。换句话说,您描述的问题与此问题相同:JavaScript set object key by variable

    在这种特殊情况下,我会这样做:

    var sourseScssFolder = 'src/scss/*.scss';
    var destCssFile = 'src/packed.css';
    var configuration = {
        sass: {
            dist: {
                options: {
                    style: 'nested'
                },
                files: {}
            }
        }
    };
    configuration.sass.dist.files[destCssFile] = sourseScssFolder;
    grunt.initConfig(configuration);
    

    【讨论】:

    • 谢谢,但在这种情况下,所有其他的 grunt 插件都清楚地理解 vanilla js。这让我有点困惑。
    猜你喜欢
    • 2021-08-12
    • 1970-01-01
    • 1970-01-01
    • 2017-10-23
    • 2022-12-17
    • 2011-01-15
    • 1970-01-01
    • 2016-05-22
    • 2018-07-22
    相关资源
    最近更新 更多