GithubHelp home page GithubHelp logo

loader's Issues

node 6.0 下报错

var Loader = function (js, css) {
  if (!(this instanceof Loader)) {
    return new Loader(js, css);
  }
  var target = {};
  target[path.extname(js)] = js;
  target[path.extname(css)] = css;

这里面的 path.extname 现在不接受 undefined

请问在Jade 中 怎么调用 loader

我尝试过
Loader('http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css')
.css('/public/stylesheets/style.css')
.done(assets, config.site_static_host, config.mini_assets)

script(type='text/javascript').
Loader('http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css')
.css('/public/stylesheets/style.css')
.done(assets, config.site_static_host, config.mini_assets);

都不行……

less @import时会报错,运行目录没有设置,是主程序的运行目录

less文档:
less.render('.class { width: (1 + 1) }',
{
paths: ['.', './lib'], // Specify search paths for @import directives
filename: 'style.less', // Specify a filename, for better error messages
compress: true // Minify CSS output
},
function (e, output) {
console.log(output.css);
});

lib/loader:
// 调用less将源文件内容翻译为CSS
less.render(content, function (err, css) {});
可以在此处用第二个参数指定路径信息

改进建议

最近在翻新 nodeclub,对于 loader 有以下几点改进建议

  1. 使用 loader 时,调用 done() 即可,而非 .done(assets, config.site_static_host, config.mini_assets)

因为这三个参数基本在每个调用 loader 的地方都是一样。
这三个参数都应在初始化 loader 时有个默认值,需要覆盖时再传参。

  1. 不必 make build,初始化时设定好 assets 目录and文件名,需要 build 的目录。在 loader 初始化时,根据是否需要 minify,对需要 build 的目录整个做 md5,如果有变动,则重新 build。

难点:需要考察对需要 build 的目录整个做 md5 的效率如何。

以上你的意向如何?

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.