NPM + Zurb Foundation + WebPack: Cannot resolve module 'foundation'

前端 未结 10 2188
挽巷
挽巷 2020-12-23 17:59

I am working on using Zurb Foundation with WebPack and NPM, without Bower.

The problem I am encountering is the same as this below:

https://github.c

10条回答
  •  伪装坚强ぢ
    2020-12-23 18:26

    It works fine for webpack if you can tell it to ignore the define test for the troublesome code below:

      if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')
         module.exports = Reveal;
      if (typeof define === 'function')
         define(['foundation'], function() {
         return Reveal;
      });
    

    The best way to do that is to use the imports-loader and set define to false.

    require('foundation-sites/js/foundation.core.js');
    require('foundation-sites/js/foundation.util.keyboard.js');
    require('foundation-sites/js/foundation.util.box.js');
    require('foundation-sites/js/foundation.util.triggers.js');
    require('foundation-sites/js/foundation.util.mediaQuery.js');
    require('foundation-sites/js/foundation.util.motion.js');
    require('imports?define=>false!foundation-sites/js/foundation.reveal.js');
    

提交回复
热议问题