-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: quickstart doc for nunjucks config #732
Conversation
这个原来并没有问题 |
https://github.com/hbrls/egg-nunjucks 这个例子跑不起来,run/config 看到是这样的
|
学习一下 node 基础吧 |
我觉得我改的和这个解释没什么不同啊,还望明示,还是说熟悉node的开发者看到上面的写法应该能意识到需要改成下面的写法 |
应该说两种都可以,但不能同时写 exports 和 module.exports,可以上网查一下 |
那个issue中给了链接,我看过了,我的意思是 egg-init 出来的写法是 module.exports,而且考虑到返回函数的灵活性更好,我猜这也是推荐的方式 所以我的问题应该是去看 egg-init 及其 template 吗,我希望的效果是上手能用,只推荐一种基于经验的最佳实践 |
没有啊,这个 node 的特性,没有最佳写法,如果不用参数何必这样写呢。 |
好的,刚刚去翻了下egg/examples/view-nunjucks/config,懂了,抱歉麻烦你这么晚 |
我也遇到了这个坑。 const path = require('path');
module.exports = () => {
const exports = {};
//...
exports.vhtml = {
enable: true,
path: path.join(__dirname, '../lib/plugin/egg-view-vhtml'),
};
return exports;
} 然后,就报错了,Cann't find ViewEngine "vhtml"。 看到Egg.js的启动log里,有内置的egg-view,egg-session等插件。 const path = require('path');
module.exports = () => {
const exports = {};
//...
exports.ejs = {
enable: true,
package: 'egg-view-ejs',
};
return exports;
} 现在报Cann't find ViewEngine 'ejs'。 直到我看到这个issuse。才发现Egg.js的插件配置 exports.static = true;
exports.reactssr = {
enable: true,
package: 'egg-view-react-ssr',
};
exports.ejs = {
enable: true,
package: 'egg-view-ejs',
}; 我改,还不行吗? |
module.exports = {
// had enabled by egg
// static: {
// enable: true,
// }
nunjucks: {
enable: true,
package: 'egg-view-nunjucks',
}
}; 这样子可以。。文档误人啊 |
这不是 Node 基础常识么 |
fix issue #525