meteor-imports-webpack-plugin icon indicating copy to clipboard operation
meteor-imports-webpack-plugin copied to clipboard

Clarifications

Open lucidprogrammer opened this issue 8 years ago • 12 comments

Interesting project @luisherranz

If i understand correctly, I run the meteor (for server code) and webpack for client code during development. How do I do the meteor build for production with this approach, any inputs?

I gave a try with the example in es2015-meteor1.3-react

After the following change, it does the build without errors. ` var MeteorImportsPlugin = require('meteor-imports-webpack-plugin');

module.exports = { entry: './client/entry.jsx', output: { path: './build', filename: 'bundle.js' }, module: { loaders: [{ test: /.jsx?$/, loader: 'babel', query: { presets:['es2015', 'react'] } }] }, plugins: [ new MeteorImportsPlugin({ ROOT_URL: 'http://localhost:3000/', DDP_DEFAULT_CONNECTION_URL: 'http://localhost:3000/', PUBLIC_SETTINGS: {}, meteorFolder: 'server', meteorEnv: {}, exclude: ['ecmascript'] }) ] };

` However, no joy visiting localhost:8080(http://localhost:8080/bundle.js does show the js file ) bundle.js:7417 Uncaught ReferenceError: meteor_runtime_config is not defined

FYI ` in bundle.js /* 77 / /**/ function(module, exports) {

module.exports = {"ROOT_URL":"http://localhost:3000/","DDP_DEFAULT_CONNECTION_URL":"http://localhost:3000/","PUBLIC_SETTINGS":{},"meteorFolder":"server","meteorEnv":{},"exclude":["autoupdate","global-imports","hot-code-push","reload","ecmascript","ecmascript"]}

/***/ },

and the offending part is var config = webpack_require(77);

__meteor_runtime_config__ = config;

` (Anyway if you define with a var to meteor_runtime_config = config; this will go away. However, additional issues like bundle.js:32275 Uncaught TypeError: Cannot read property '_' of undefined (root =this, so not defined etc. ) This is a promising project and could be really useful to many. Could you check this example with 1.3-react with the latest [email protected] and see if this package be updated with the necessary fixes. It can be great and well appreciated. Tks

lucidprogrammer avatar Apr 25 '16 10:04 lucidprogrammer

@lucidprogrammer Did you manage to fix these?

reohjs avatar Jul 13 '16 18:07 reohjs

@lucidprogrammer Sorry for the delay on this one. I missed it somehow.

Meteor build should be used only for the server. For the client, use webpack instead.

Does that solve your question?

luisherranz avatar Jul 14 '16 08:07 luisherranz

@luisherranz The __meteor_runtime_config error is coming from the client (webpack) on this line because it hasn't been defined yet

This also happens in the es2015-meteor1.3 example

I think @lucidprogrammer wanted to have a single meteor app including the client bundle for which my approach would be:

cd dev-app/client
webpack // this outputs the bundle.js file to the build/ directory
cd path/for/production
meteor create production-app
// copy the client bundle into a client/ folder
// copy the server files into a server/ folder
meteor build

reohjs avatar Jul 14 '16 11:07 reohjs

I think @lucidprogrammer wanted to have a single meteor app including the client bundle.

If you want to be able to use meteor build for the client, maybe this project is a better fit: https://github.com/thereactivestack/meteor-webpack/tree/master/packages/webpack/

@luisherranz The __meteor_runtime_config error is coming from the client (webpack) on this line because it hasn't been defined yet

I see. It looks like it doesn't like that global declaration. Could you please check if this works?

window.__meteor_runtime_config__ = config;

luisherranz avatar Jul 14 '16 12:07 luisherranz

This was long ago. This is what i ended with

https://github.com/lucidprogrammer/mantra-sample-blog-app

lucidprogrammer avatar Jul 14 '16 12:07 lucidprogrammer

@luisherranz That fixes it, yes

reohjs avatar Jul 14 '16 12:07 reohjs

Refer to this, it fixes. This the one i used in that sample https://github.com/lucidprogrammer/meteor-imports-webpack-plugin

lucidprogrammer avatar Jul 14 '16 13:07 lucidprogrammer

@luisherranz That fixes it, yes

Great! I'm leaving right now but I will upload a fix on Monday.

luisherranz avatar Jul 14 '16 15:07 luisherranz

@lucidprogrammer that's so cool. I am glad this is useful for somebody! (as I am not using it myself).

Would you consider making a PR with your modifications so anybody can benefit?

luisherranz avatar Jul 14 '16 15:07 luisherranz

Yes will do

lucidprogrammer avatar Jul 14 '16 15:07 lucidprogrammer

Will do in the weekend. Tks

lucidprogrammer avatar Jul 14 '16 15:07 lucidprogrammer

I have fixed the __meteor_runtime_config__ problem and published a new version to npm.

luisherranz avatar Jul 18 '16 07:07 luisherranz