Comments (7)
I don't see why something like this wouldn't be possible. Would it be possible for you to give it a go and link me to the repo when you get stumped with something?
from webpack-book.
Hi @bebraw,
https://github.com/chemoish/react-webpack.git
Commits are segmented in the order I am following his article.
Eventually, I would like to figure out routing and isomorphic design (which i think pete-hunt just published something this weekend).
🙇
Currently,
// webpack.config
{
entry: {
...
pageHome: './src/components/Home.js',
},
output: {
...
path: 'build'
}
}
// app
require.ensure([], function (require) {
var Home = require('../build/pageHome.js');
React.render(<Home />, $('#main').get(0));
});
// pageHome
module.exports = React.createClass({
render: function () {
return (
<h1>Home</h1>
);
}
});
And I notice that webpack is creating a file in memory called 1.1.js
—which seems fine, or whatever, but it looks like its running ./src/components/Home.js
in a eval()
and that function is returning an empty {}
(I guess because there is no module.export in that generated file).
from webpack-book.
It also looks like its being wrapped in webpackJsonp
, which is probably the culprit.
from webpack-book.
If you relax the multiple entry point requirement, you get
diff --git a/package.json b/package.json
index 1b5c7a8..a123588 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,7 @@
"description": "Testing out react-webpack: http://christianalfoni.github.io/javascript/2014/12/13/did-you-know-webpack-and-react-is-awesome.html",
"main": "index.js",
"scripts": {
+ "build": "webpack",
"dev": "webpack-dev-server --devtool eval --progress --colors --content-base build",
"test": "echo \"Error: no test specified\" && exit 1"
},
diff --git a/webpack.config.js b/webpack.config.js
index 8b47910..54fd39a 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -8,8 +8,8 @@ module.exports = {
],
app: './src/app.js',
- pageHome: './src/components/home.js',
- pageSetting: './src/components/setting.js'
+ //pageHome: './src/components/Home.js',
+ //pageSetting: './src/components/Setting.js'
},
output: {
You can try applying that with git apply
.
There was a conflict between entry points and CommonsChunkPlugin
so I needed to comment out the entry points.
Now the question is can we find some acceptable compromise here given having both is not possible?
from webpack-book.
So, do I understand correctly that you cannot achieve…
Multiple entry points (bundles), which have their common code extracted, and then the bundles themselves lazy loaded when necessary?
I have already went through consolidating it down to one entry point (which there are many examples of out there), but then you cannot extract out common code from said entry points.
Shared.js
gets embedded per lazy loaded file.
from webpack-book.
Yeah, some kind of a compromise is needed by the looks of it unless I'm understanding something wrong. One way to work around the entry restriction would be to generate separate bundles per entry. You can achieve this with some extra fiddling (run webpack through Node cli and alter entry).
from webpack-book.
Darn. It was so close to being perfect.
I'll inquire how Pete hunt is achieving it in his how to examples.
Thanks.
On Aug 10, 2015 12:05 PM, "Juho Vepsäläinen" [email protected]
wrote:
Yeah, some kind of a compromise is needed by the looks of it unless I'm
understanding something wrong. One way to work around the entry restriction
would be to generate separate bundles per entry. You can achieve this with
some extra fiddling (run webpack through Node cli and alter entry).—
Reply to this email directly or view it on GitHub
https://github.com/christianalfoni/react-webpack-cookbook/issues/39#issuecomment-129568052
.
from webpack-book.
Related Issues (20)
- Enhance section on Hot Module Replacement HOT 7
- Purifying CSS when using React HOT 1
- request to translate into Indonesian HOT 1
- webpack 4 HOT 8
- Autoprefixing missing sample HOT 3
- Error on annotate-console-log syntax and annotation problem HOT 4
- Copybody Corrections HOT 2
- extract-text-webpack-plugin doesn't extract a file HOT 2
- developing - images directory had incorrect path HOT 1
- report one code error HOT 1
- building - tidying up - [email protected] replace default export with named export HOT 2
- favicons-webpack-plugin outdated dependencies HOT 1
- ew HOT 1
- Feed back and suggestions HOT 3
- Separating CSS: Code not working HOT 3
- WebSocket connection to 'ws://[::]:8080/wps' failed HOT 2
- in safari, not passing host fails the live reload of code HOT 2
- dynamic import about terser error HOT 16
- "watch" script throwing an error HOT 4
- css-loader now supports absolute imports
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 webpack-book.