Webpack with support

I would like to download node packages better, and only if they do not exist, download the bower package.

I would just use the node package only as recommended on the Webpack website, but I need to download the library, which is only in bower, https://github.com/Stamplay/stamplay-js-sdk and https://github.com / Stamplay / angular-stamplay

Try bower-webpack-plugin

I installed https://github.com/lpiepiora/bower-webpack-plugin

But when I run webpack-dev-server -d --watch , the error appears in the 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. (anonymous function) @ app.js: 8__webpack_require__ @ bootstrap 6cecf8d96fb5a1205f10: 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. 39__webpack_require__ @ bootstrap 6cecf8d96fb5a1205f10: 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. 

Try using ResolverPlugin (see Docs on the Internet )

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, as mentioned here , the Stamplay object Stamplay incorrect!

Attempt with CDN and angular -webpack-plugin

First add the script tag to index.html ..

Second, add external elements to webpack.config ..

 externals: { stamplay: 'Stamplay' }, 

And finally, new AngularPlugin in plugins on webpack.config

Thus, worsks , but I can not use angular-stamplay when I try, an error in the Stamplay module Stamplay : (

See the thread with this change here.

The full project is here: https://github.com/Ridermansb/webpackBowerStarter

+6
angularjs bower webpack webpack-dev-server
Nov 03 '15 at 14:52
source share
1 answer

Ok, tried your project from git https://github.com/Ridermansb/webpackBowerStarter

And as mentioned in https://github.com/lpiepiora/bower-webpack-plugin/issues/20 I also had a problem with Cannot resolve module 'stamplay-js-sdk' , then in the webpackBowerStarter directory I did bower install stamplay-js-sdk , then sudo npm run build and voila! That was done.

In npm run start , which is the same as webpack-dev-server -d --watch , I get http: // localhost: 8080 / webpack-dev-server / as http: // localhost: 8080 / webpack-dev-server / And the console says enter image description here

sry if u meant something else. Does your problem solve?

+2
Nov 05 '15 at 19:48
source share



All Articles