I'm trying to use webpack to handle the building of an electron application. I would like to have an index.html that uses script tags to import/require a react client.js file, and have that client.js file and its required files require the entire application.
My folder structure looks like this:
Project
|
| --/app
|
| ----/gui
| ------/flux
| ------/fonts
| ------/html
| ------/images
| ------/react
|
| ----/lib
| ------ /custom-modules ...
| ----package.json (application)
|
|
| --/dist
| .babelrc
| webpack.config.js
| package.json (dev)
I would like to develop the app in ./app, run webpack or webpack-dev-server and have a complete and functional copy of the app transpiled and minified in ./dist.
Relevant chunk of Webpack.config.js:
module.exports = {
context: path.join(__dirname, '/app'),
devtool: debug ? 'inline-sourcemap' : null,
entry: {
main: './webpack-hook.js'
},
output: {
publicPath: '/assets/',
path: path.join(__dirname, '/dist/'),
filename: 'js/gui.js'
},
module: {
loaders: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}
},
{
test: /\.html$/,
loader: 'file-loader?name=[name].[ext]'
},
{
test: /\.css$/,
loader: 'file-loader?name=css/[name].[ext]'
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader?name=images/[name].[ext]'
},
{
test: /\.(ttf)$/,
loader: 'file-loader?name=fonts/[name].[ext]'
}
]
}
}
In webpack-hook.js I have a single line: require('./gui/html/index.html');
What I want/expect is to have all of the dependencies found by webpack and bundled into dist/images, dist/fonts, and so on. As of right now, I just get an index.html file copied into dist.