将自定义Modernizr构建添加到Gatsby站点

问题描述 投票:1回答:1

将自定义Modernizr构建添加到Gatsby站点的最佳方法是什么?

一种想法是在modernizr.js文件夹中包含static/文件,然后包含在布局组件中导入该文件的脚本标记。但这并不是最适合Gatsby的方法。

任何其他建议将非常有帮助!

gatsby modernizr
1个回答
0
投票

他们有一个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!');
  }
});
© www.soinside.com 2019 - 2024. All rights reserved.