D
D
d-virt2016-06-01 20:26:11
JavaScript
d-virt, 2016-06-01 20:26:11

How to build js modules (webpack)?

Hello.
index.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './containers/app';

ReactDOM.render(
    <App/>,
    document.getElementById('app')
);

When you call the webpack command, everything compiles perfectly into 1 build.js file, runs in the browser and works.
But he wants it to be something like this:
import React from 'react';
import ReactDOM from 'react-dom';

const App = requery('app');

ReactDOM.render(
    <App/>,
    document.getElementById('app')
);

And also, when compiling, get two files build.js, app.js and when loading build.js into the browser, app.js was automatically pulled up.
Please, tell me how this can be implemented?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2016-06-01
@d-virt

https://webpack.github.io/docs/code-splitting.html
This code will not work directly, because automatically downloading an additional file is an asynchronous action.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question