Comments (15)
Hey @nigel-dewar,
if you start the application with npm start
the start-command "start": "webpack-dev-server --inline --progress --port 8080",
should start a webpack-dev-server which automatically refreshes the browser. Note that it does not start the browser automatically. You have to do this manually by browsing to localhost:8080
.
HTH
Fabian
from angularwebpackvisualstudio.
Hi! I hate command prompt :-)
I added "hot module replacement" like this:
- add to package.json
"webpack-hot-middleware": "^2.10.0", "aspnet-webpack": "^1.0.11",
- add to project.json
"Microsoft.AspNetCore.SpaServices": "1.0.0-*"
- add to Startup.cs, before "app.UseDefaultFiles();"
if (env.IsDevelopment()) { app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); }
- modify webpack.dev.js
output: { path: path.join(__dirname, 'wwwroot'), filename: 'dist/[name].bundle.js', publicPath: "/" },
- modify boot.ts
`import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app/app.module';
if (module['hot']) {
module['hot'].accept();
module['hot'].dispose(() => { platform.destroy(); });
}
else {
enableProdMode();
}
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
`
It's all. Run debug from VS and get hot replacment.
from angularwebpackvisualstudio.
I think building automatically for AOT is also a good idea.
File project.json
"scripts": {
"prepublish": [ "npm run ngc && npm run webpack-prod" ]
}
from angularwebpackvisualstudio.
Sounds cool. I will have a look a this
from angularwebpackvisualstudio.
Hello @amivit
concerning the browser-sync: Did you see we support the webpack-dev-server already?
BR
Fabian
from angularwebpackvisualstudio.
Hey guys. Sounds awesome 👍 And yes I have! So I suppose it is just a matter of installing the "browser-sync-webpack-plugin" and tweaking the webpack.dev.js file to include the plugin.
Regarding HMR, I hope it's also as simple as using the --hot paramater!?? Another potentially helpful link: http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/
from angularwebpackvisualstudio.
Hey Fabian, awesome work on this?
I have a query, and please dont excuse it as dum, I read the doco on this repo, and it all looks good. But when you run the solution, should we be expecting in watch mode, when we make changes to the Angular TS code and webpack does its thing, that our browser will refresh? Or is this not possible?
Is this what this initial rowsersync & Hot module request is in reference to?
from angularwebpackvisualstudio.
Thanks Fabian, I will give it a shot. Cheers
Sent from Samsung Mobile
-------- Original message --------
From: Fabian Gosebrink
Date:13/09/2016 15:45 (GMT+10:00)
To: damienbod/Angular2WebpackVisualStudio
Cc: nigel-dewar , Mention
Subject: Re: [damienbod/Angular2WebpackVisualStudio] Browsersync & Hot module replacement? (#4)
Hey @nigel-dewarhttps://github.com/nigel-dewar,
if you start the application with npm start the start-command "start": "webpack-dev-server --inline --progress --port 8080", should start a webpack-dev-server which automatically refreshes the browser. Note that it does not start the browser automatically. You have to do this manually by browsing to "localhost:8080".
HTH
Fabian
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//issues/4#issuecomment-246580751, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AI94WIWKCyFjQiAm-TdlYEeN_1v2Uwl9ks5qpjhxgaJpZM4JqWdG.
from angularwebpackvisualstudio.
HI @maksir, really cool, thanks, I will try it out.
Greetings Damien
from angularwebpackvisualstudio.
With the use of HMR through the Microsoft.AspNetCore.SpaServices library, I ask: what is the possibility of using Server Rendering too?
I think it would be perfect there, top of the top performance.
(With AOT and Server rendering)
I have been trying for 1 full day to add and configure this template here, but I can not seem to make it work.
I'll keep trying.
If someone can, could they post the code snippet?
from angularwebpackvisualstudio.
Hi @maksir, have you the working example?
from angularwebpackvisualstudio.
Hi @maksir / damienbod,
I tried your solution but keep running into problems.
When I just follow your changes to enable HMR I run into a MemoryFileSystem exception described here.
If I fix that by putting a backslash before the webpack output folder my index.html cannot be found anymore.
Can you please share your solution to get HMR working?
Please find attached my NOT working example.
Regards,
Jeroen
AAC3.zip
from angularwebpackvisualstudio.
Hi @Geronimo2015 I have not looked at HMR in detail yet. I will have a look at this next, will not have time until later in the week, this issue, problem has been opened for a while now.
Greetings Damien
from angularwebpackvisualstudio.
@Geronimo2015 @dbratsun @amivit
This now works, you can use the HMR using the dev build, and then the npm start.
I'll update the docs this week, let me know if you have any other issues.
Greetings Damien
from angularwebpackvisualstudio.
https://damienbod.com/2017/02/01/hot-module-replacement-with-angular-2-and-webpack/
from angularwebpackvisualstudio.
Related Issues (20)
- Prod deployment issue HOT 4
- 502.5 when deploying to Windows Server 2016 HOT 1
- Your Custom Project vs Dotnet Angular Template? HOT 5
- Looking for the HMR specific code in the zip HOT 2
- AOT setup questions HOT 2
- Angular-cli support HOT 2
- Update to Webpack 4 HOT 1
- Install webpack-cli error HOT 1
- AOT Build Fail HOT 1
- Annoying build warnings
- adding styleUrls gives error HOT 1
- Can not start project HOT 1
- Controller not being registered when running with webpack-dev-server HOT 4
- Could not find a declaration file for module AppModuleNgFactory HOT 6
- error in creating a veu.js with bootstrap using npm HOT 1
- Use optimization.splitChunks instead of separate entry points (Webpack 4)
- When running with watch, assets fail to regenerate on save HOT 1
- Remove raw-loader as latest version no longer works or find a solution HOT 1
- Internet Explorer Polyfills missing HOT 1
- Updating webpack v3.8.1 to v4.41.2 in existing application
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angularwebpackvisualstudio.