GithubHelp home page GithubHelp logo

CSS打包问题 about grunt-cmd-concat HOT 4 OPEN

spmjs avatar spmjs commented on June 2, 2024
CSS打包问题

from grunt-cmd-concat.

Comments (4)

n9sr5y avatar n9sr5y commented on June 2, 2024

options.css2js

Type: Function Default value: null

If a javascript module required a css, the css should be transported to js.

You can get a css2js function from grunt-cmd-transport :

var style = require('grunt-cmd-transport').style.init(grunt);

grunt.initConfig({
concat: {
foo: {
options: {
css2js: style.css2js
}
}
}
});

上面对 变量 console.log(style.css2js)

显示undefined

from grunt-cmd-concat.

amriogit avatar amriogit commented on June 2, 2024

我也很好奇,为什么顶级IDcss是用.css文件,相对ID用的就是.css.js文件?

另外,那个css2js选项我是这样用的:

var css2js = require('grunt-cmd-transport').style.css2js

from grunt-cmd-concat.

n9sr5y avatar n9sr5y commented on June 2, 2024

transport : {
options : {
parsers : {
'.css' : [style.css2jsParser],// 配置应该是这样的,然后看是否需要seajs的importStyle插件,不然需要去删除源码的css2js代码片段
// '.css' : [style.cssParser],
'.js' : [script.jsParser],
'.tpl' : [template.tplParser],
'.handlebars': [template.handlebarsParser],
'.html' : [text.html2jsParser]
}
},

from grunt-cmd-concat.

amriogit avatar amriogit commented on June 2, 2024

我是直接改成:

'.css' : [style.cssParser, style.css2js]

parsers的值支持多个处理器数组写法,我试过有效

题外话:
这里的options不能够像jQuery.extend那样深度复制,源码用的应该是underscore.extend,如果能用类似jQeury.extend就好了。对于这种引用类型的选项依然能够复制,且保持期望的格式,不然只要加一个parsers就得全加,显得多余且麻烦

from grunt-cmd-concat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.