borysn / spring-boot-angular2

spring boot backend, angular2 frontend with webpack, typescript, sass, bootstrap4, karma, jasmine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integrate bower dependency

cridmann opened this issue · comments

Hello,

First of all, thanks for the nice template!

I'm wanting to use this template if possible, but I'm struggling to incorporate a bower dependency into the webpack2 config. Am I right in my understanding that the gradle-node plugin cannot be used for this, and thus I would need to include something like https://github.com/craigburke/client-dependencies-gradle ?

I added frontend/bower.json, and changed my webpack.common.js to use

    resolve: {
        modules: [helpers.root('src'), "node_modules", "bower_components"],
        descriptionFiles: ['bower.json', 'package.json'],
        extensions: ['.js', '.ts', '.css', '.scss', '.json', '.html']
    },

The gradle-node plugin of course does not install the bower_components, thus I have to manually bower install

Even when I do so, I can't figure out how to include a downloaded bower dependency in the actual code. I'll keep trying and will update any findings.

@cridmann you can try one of these two options for installing automatically

  1. just call bower from within scripts sections of the package.json for npm. please refer to the postinstall section of the npm scripts doc
  2. you can try an npm package called bower-installer

as far as incorporating bower with webpack, please refer to the usage with bower webpack doc

@borysn - the first solution ended up working well.

As far as bower + webpack, I did see that doc, but it seems things changed when they upgraded to webpack2. See: lpiepiora/bower-webpack-plugin#39. Anyways, I think my solution that I pasted in my original comment was actually working. However, the complication is that the bower dependencies are also polymer web components, so there are additional configs you need to provide webpack for it to work. I'm currently looking into https://github.com/aruntk/wc-loader for that.

As this isn't too related to this template, I'll go ahead and close this ticket. Thanks for the help!