Would I like to load preferably the node packages, and only if not exist, loads the bower package.
I would just use the node package only as recommended in Webpack site, but I need to load a library that is just in bower, https://github.com/Stamplay/stamplay-js-sdk and https://github.com/Stamplay/angular-stamplay
I installed https://github.com/lpiepiora/bower-webpack-plugin
But when I run webpack-dev-server -d --watch
the error is displayed in chrome console:
Uncaught TypeError: angular.module is not a function(anonymous function) @ app.js:8__webpack_require__ @ bootstrap 6cecf8d96fb5a1205f10:19(anonymous function) @ bootstrap 6cecf8d96fb5a1205f10:39__webpack_require__ @ bootstrap 6cecf8d96fb5a1205f10:19(anonymous function) @ bootstrap 6cecf8d96fb5a1205f10:39(anonymous function) @ bootstrap 6cecf8d96fb5a1205f10:39
angular.js:68Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
In webpack.config i add..
plugins: [
...
, new webpack.ProvidePlugin({
Q: 'q',
store: 'store.js',
Stamplay: 'stamplay-js-sdk'
})
, new webpack.ResolverPlugin(
[
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
], ["normal", "loader"]
)
],
....
resolve: {
root: [
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'bower_components')
],
But, like mention here the Stamplay
object is not correct!
First add script tag into index.html
..
Second, add externals in webpack.config ..
externals: {
stamplay: 'Stamplay'
},
And finally .. new AngularPlugin
into plugins
on webpack.config
This way, worsks but I cant use angular-stamplay
, when I try, a error in module stamplay
apper. :(
See branch with this change here
The full project is here: https://github.com/Ridermansb/webpackBowerStarter
Bower is a package manager for the web. It offers a generic, unopinionated solution to the problem of front-end package management, while exposing the package dependency model via an API that can be consumed by a more opinionated build stack.
1. Bower has been deprecated by its creators. After a long and heated debate on Github, the creators of Bower decided it does not add value to the current web development stack and should be discontinued.
Bower is a command line utility. Install it with npm. Bower requires node, npm and git.
Bower is a front-end dependency tool to manage HTML, CSS, JS for our front-end packages. The most used for client-side dependencies are like jquery dependency management or other front-end package dependency management.
Ok, tried your project from git https://github.com/Ridermansb/webpackBowerStarter
And as mentioned at https://github.com/lpiepiora/bower-webpack-plugin/issues/20 I too had that Cannot resolve module 'stamplay-js-sdk'
issue , then in webpackBowerStarter directory I did bower install stamplay-js-sdk
then sudo npm run build
and voila! It was done.
On npm run start
which is same as webpack-dev-server -d --watch
I get http://localhost:8080/webpack-dev-server/ like
And console says
sry if u meant something else. Does this resolves your issue ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With