-
Notifications
You must be signed in to change notification settings - Fork 44
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
Webpack configuration example #32
Comments
I second this! Definitely need to find a way to use vaadin with Webpack. |
I'm third then! |
There are such package https://github.com/jondum/polymer-loader |
Okay, I got an example working. Basically, I just added the necessary elements into the HTML file template finally produced by Webpack and then just called the Angular 2 selector in the body of the HTML. Here is a gist: https://gist.github.com/httpdigest/b81d30bbe3cacabbbc43893a24e99801 |
I just do. module.exports = {
...
plugins: [
....
new CopyWebpackPlugin([{
from: 'bower_components',
to: 'assets/bower'
}], {
ignore: [
'*.scss',
'*.ts',
'*.json',
'*.yml',
'*.md',
// '*.svg',
'*.jpg',
'*.gif',
'*.png',
'*.adoc'
]
}),
....
],
link: [
....
{rel: "import", href: "/assets/bower/vaadin-grid/vaadin-grid.html"},
]
}; |
Here is not the right place to solve. |
@jumper423 you can change the bower directory in .bowerrc: {
"directory": "assets/bower/"
} |
@platosha thank you |
@jumper423 how about using vulcanize? It can bundle all the HTML Imports you use with their dependencies into a single HTML file, which you can then feed to webpack. |
@platosha There is an example? |
Vulcanize is the tool! :) @jumper423 as for an example:
Of course you can also add a script to package.json:
index.html is supposed to be your html file with the imports of the vaadin component html files. The output is the out.html with all such components concatenated into your html file. |
Okay, I just found that it does not work with Vulcanize out of the box. Vulcanize includes the HTML files and the referenced JavaScript files, but it does not remove the "src" attribute of the inlined <script> elements. This leads Chrome to think that it should download the script. The problem is with the vaadin-grid/vaadin-grid.html file which references "vaadin-grid.min.js". After vulcanize ran over this, it will inline the script but will keep a "src" attribute pointing to "bower_components/vaadin-grid/vaadin-grid.min.js" on the script element. This leads Chrome to wanting to download this script, which it will not find, since the whole point was to not have the bower_components folder distributed. EDIT: |
Now that angular-cli is about switching to webpack. I was able to migrate my project to webpack but when I run
|
@httpdigest Hi, how you managed to import all the files? I try to import all the dependencies listed in the Angular 2 tutorial page for vaadin in a import file and then i vulcanize this file. And finally I'm requiring the vulcanized file. And i always get a Polymer error. TypeError: undefined is not an object (evaluating 'Polymer.Settings'). Did you encounter with an error like this?. Thanks in advance. |
@5amfung to eliminate Webpack warning try add line in webpack.common.js file
|
@vitoexe angular-cli not provides a webpack.common.js file. |
Hi all, What is currently the best way to load vaadin/angular2-polymer in angular-cli@webpack projects? |
angular-cli@webpack @Richard87 My solution is: launch Angular from main.ts after WebComponentsReady by require document.addEventListener('WebComponentsReady', function () {
require('./main-after-listener.ts');
}); main-after-listener.ts import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule, environment } from './app/';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule); This is work also in Firefox. Temporary solution to eliminate WARNING in ./~/@vaadin/angular2-polymer/index.js in node_modules/angular-cli/addon/ng2/models/webpack-build-common.ts You can add preLoaders: [
{
exclude: [
path.resolve(projectRoot, 'node_modules/@vaadin/angular2-polymer'), But this is bad solution! This should be added outside node_modules |
There is a guide for Angular CLI Webpack projects. Please see: https://github.com/vaadin/angular2-polymer/blob/master/docs/ng-cli-webpack.adoc for the complete step-by-step instructions. cc @cementito @Richard87 @liongoncalves |
@liongoncalves Running on Chrome has no problem, but I got your same And I'm using this approach to bootstrap my app.
|
Hello @platosha ! This documentation link is "out of date". The directory Futhermore, when you perform |
@5amfung @liongoncalves Did you figure out the TypeError: undefined is not an object (evaluating 'Polymer.Settings') issue? |
@ythanaseelan I have the same error. Any idea ? |
@cdupetit The issue happens for me only for jasmine testing with phantomjs. Couldnt get any workaround for that. So I ended up not accessing the polymer components in the jasmine tests and limited my testing only to the code written for Angular layer. |
@liongoncalves same issue just on safari on my website (http://quentinchapelle.com) and for the moment i haven't find any solution :( Edit: problem solve thank to #57 there is a guide here to resolve this problem https://github.com/vaadin/angular2-polymer/blob/master/docs/ng-cli-webpack.adoc |
I've built a package to handle polymer/webcomponents files and html imports (with code reload support) https://github.com/aruntk/wc-loader. check out. |
Hello,
any hints on how to set-up the project with Webpack?
I'm struggling to find the equivalent of
to ensure the load order.
The text was updated successfully, but these errors were encountered: