I am trying to use the plugin Galleria with Webpack. Without Webpack galleria can be used as:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script src="galleria/galleria-1.4.min.js"></script>
<script>
(function() {
Galleria.loadTheme('https://cdnjs.cloudflare.com/ajax/libs/galleria/1.5.7/themes/classic/galleria.classic.min.js');
Galleria.run('.galleria');
}());
</script>
The theme can also be loaded manually instead of using the method loadTheme:
<link rel=”stylesheet” type=”text/css” href=”https://cdnjs.cloudflare.com/ajax/libs/galleria/1.5.7/themes/fullscreen/galleria.classic.min.css” />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/galleria/1.5.7/galleria.min.js”></script>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/galleria/1.5.7/themes/classic/galleria.classic.min.js”></script>
<script>
(function() {
Galleria.run('.galleria');
}());
</script>
With WebPack I added the following code to Index.js:
import galleria from 'galleria';
import '../../node_modules/galleria/dist/themes/classic/galleria.classic.css';
import '../../node_modules/galleria/dist/themes/classic/galleria.classic.js';
window.Galleria = galleria;
(function() {
Galleria.run('.galleria');
}());
When I run it I get the errors:
No theme CSS loaded.
Init failed: Galleria could not find the element "undefined".
Any idea how to use Galleria with Webpack?
Created a simple repo with webpack and galleria for you.
Steps are:
shimmingas documented here:jqueryandgalleriaas dependencies to your project:npm i -S jquery gallerialoadThemeandrunGalleria methods:To see project working please run
npm run start.UPD:
To copy minified theme files you can use
CopyWebpackPlugin:npm i -D copy-webpack-pluginloadThemecall:Galleria.loadTheme('assets/galleria.classic.js');UPD2:
Updated repo with webpack
importsusage. Please see difference in this PR or this branch. Main changes are:galleria.classic.cssfile to be used withcopy-webpack-pluginand loaded as<link rel="stylesheet" type="text/css" href="assets/galleria.classic.css">because I found in source code thatcsscan be loaded only throughlinkorscripttags or dynamically (loadThemecall), otherwiseNo theme css loadedwill be printed.imports-loaderand used it in inline style.