Title: Webpack - React ES6 transpile every template (src to dist)
Tags: reactjs;webpack;html-webpack-plugin
Question: I am using webpack for react(es6) project.
My problem
I have built react app with ES6, so everywhere i have used import keyword for dependency. Now for server side rendering i am using NodeJS so its not support import yet. For this i have to use require instead of import.
Now i have used webpack for bundling my app, but it always generate final bundle file (single.bundle.js), That's why i am not able to import chunk of transpiled code for server side rendering.
Solution
If it is possible to transpile every file (src to dist), then i can import this es5 file into nodejs server code.
Question
Is this possible with webpack to transpile whole folder with same out put rather than bundle file ?
Otherwise i have to use grunt or gulp. :(

Comment: @Ursus package.json or webpack.config.js

Comment: @Ursus https://gist.github.com/Nishchit14/ba6edd1b36bb5161206847acf49072b3

Comment: @Ursus https://gist.github.com/Nishchit14/82916291809827e2b6113e934adcffed

Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/116790/discussion-between-nishchit-dhanani-and-u-r-s-u-s).

Comment: It'd be helpful if you showed your `package.json`

Comment: Let's see both please

Comment: Sorry can't see anything wrong with them.


Here is another answer: You can use webpack for server too. It will transpile to webpack server bundle only your specific code containing react and excluding node_modules by externals option. Here is example of ```webpack.config.js``` for server side

```var nodeModules = {};
fs.readdirSync('node_modules')
    .filter(function(x) {
        return ['.bin'].indexOf(x) === -1;
    })
    .forEach(function(mod) {
        nodeModules[mod] = 'commonjs ' + mod;
    });

module.exports = {
    entry: './src/server.js', 
    output: {
        path: __dirname,
        filename: 'server.js'
    },
    target: 'node',
    node: {
        console: false,
        global: false,
        process: false,
        Buffer: false,
        __filename: false,
        __dirname: false,
    },
    externals: nodeModules,
}
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:07/08/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<reactjs><webpack><html-webpack-plugin>', 'Title': 'Webpack - React ES6 transpile every template (src to dist)', 'ViewCount': 629, 'id': 38264260, 'user_AboutMe': '<p>Right now I am busy building an API platform named <a href="https://firecamp.io" rel="nofollow noreferrer">Firecamp</a></p>\n<p>Firecamp is a Multi-protocol API Platform for API development. It offers dedicated GUI clients, tools, and services agnostically protocols and API-styles like Rest, GraphQL, MQTT, WS, Kafka, etc.</p>\n', 'user_AccountId': 3380237.0, 'user_DisplayName': 'Nishchit', 'user_Reputation': 17268.0, 'user_Views': 1211.0, 'user_id': 2837412.0}}