将自定义 Modernizr 构建添加到 Gatsby 站点的最佳方法是什么?
一种想法是在 static/
文件夹中包含一个 modernizr.js
文件,然后在布局组件中包含一个导入该文件的脚本标签。但这并不是对 Gatsby 最友好的方法。
任何其他建议都会非常有帮助!
最佳答案
他们有一个 npm 包 modernizr .也许试试看?
在 /src/pages/index.js
添加:
// Listen to a test, give it a callback
Modernizr.on('testname', function( result ) {
if (result) {
console.log('The test passed!');
}
else {
console.log('The test failed!');
}
});
关于gatsby - 将自定义 Modernizr 构建添加到 Gatsby 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55591828/