-
Notifications
You must be signed in to change notification settings - Fork 604
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
Loading with webpack #225
Comments
Got it loading by installing In other words: Disabling AMD for Flickity and all of its deps solved my problem. |
This worked for me also thank you. |
A better solution might be to load the packaged version instead |
@PaulTondeur I went down that route and it's no good. It's full of UMD loaders that for some reason are incompatible with webpack. |
Really? It seems to be working pretty well for me here. No issues at all. |
Oh, circumstances must've changed since I posted this issue, then. Hopefully the next googler can find a solution in this thread! |
Nice! That's why I left the comment :-) |
hummm… still getting the errors mentionned initially, even with requiring flickity.pkgd.js |
Did you try my trick?
|
sorry, i was confused by the
|
Great! |
Added Webpack instructions to docs Install Flickity and imports-loader with npm.
In your config file, module.exports = {
module: {
loaders: [
{
test: /flickity/,
loader: 'imports?define=>false&this=>window'
}
]
}
}; (This hack is required because of an issue with how Webpack loads dependencies. +1 webpack/webpack#883 to help get this issue addressed.) You can then // main.js
var Flickity = require('flickity');
var flkty = new Flickity( '.gallery', {
// options...
}); Run webpack. webpack main.js bundle.js
|
FYI, this will break if you are using npm3 due to the flattening of dependencies, so your webpack loader will need to look sort of like so:
|
FWIW I fixed my issue with this by installing
|
I followed all of the other instructions on the page, and this is the only one that worked for me.
|
Is it me, or does this fix only work one directory level deep? As soon as I use Flickty in a component e.g. src > components > partials > file.js, I get the error again. Moving the file up to the components directory works. Any ideas? |
I have updated the Flickity Webpack instructions to use // In your config file, webpack.config.js, add these resolve aliases.
module.exports = {
resolve: {
alias: {
'eventEmitter/EventEmitter': 'wolfy87-eventemitter/EventEmitter',
'get-style-property/get-style-property': 'desandro-get-style-property/get-style-property',
'matches-selector/matches-selector': 'desandro-matches-selector/matches-selector',
'classie/classie': 'desandro-classie/classie'
}
}
}; These aliases will not be required in the next major version of Flickity, v2. |
Thanks. Here is my config file:
|
Moving to webpack's I was still getting undefined |
how strange. I've tried both of the fixes together, and still get the undefined window variable when importing it into any file that is not the entry file. would you be able to share your config file to see if i have anything glaringly wrong? i imagine you will be using flickity a few folder levels dow |
@gitpullen, including these
|
Cheers. |
Flickity v2 is out now and has much improved Webpack integration. No more config required. You can |
I'm now closing this issue as resolved. If you run into an issue with Webpack and Flickity, please open a new issue. |
@desandro the workarounds above still relevant for |
@lmartins @desandro Have an example of what I'd need to make https://github.com/metafizzy/flickity-fullscreen work with es6 imports? The webpack error looks like it's looking side of
Tried with and without the Was attempting to use it like so:
|
@zslabs Thanks for catching this bug. Looks like the module definitions should be: // AMD
'flickity/js/index'
// CommonJS
'flickity' I'll add this fix in the next release for |
@desandro Ah that's great! Thanks so much - was definitely throwing me for a loop 😏 |
I'm getting this error:
When doing 'npm run dev'. Using Laravel webpack.mix.js so that may be part of the issue. Anyone else run into this error? |
@camaech Flickity requires a browser environment. If you are trying to run Flickity server side, you'll need to skip over loading it as it requires |
When I use the instructions here (https://flickity.metafizzy.co/api.html#flickity-setjquery), I get the same error. Window is not defined. Not sure what else to try. |
Fixes for This issue is now pretty old, covering deprecated instructions which can mislead new users. I'm locking the issue as such. Please open a new issue if you run into trouble with Flickity and Webpack. |
Has anyone successfully loaded
flickity
via npm with webpack?var Flickity = require('flickity');
Ends up in this, for me:
In other words, webpack doesn't play nice with the UMD loader for some reason.
With some
exports-loader
/imports-loader
tweaking I was able to load the actualdist/flickity.pkgd.js
but then I got stuck on it trying to loadjquery-bridget
andjquery
which I didn't think was an actual dependency.Is
flickity
dependent onjquery
?Thanks!
The text was updated successfully, but these errors were encountered: