Created
March 16, 2017 21:31
-
-
Save olegpolyakov/ad35013e84f756ddd7dc52d56b83880b to your computer and use it in GitHub Desktop.
Webpack configuration for React
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
module.exports = { | |
entry: { | |
library: './src/library/index.jsx', | |
player: './src/player/index.jsx', | |
vendor: ['react', 'react-dom'] | |
}, | |
output: { | |
path: path.relative(__dirname, 'public'), | |
filename: '[name]/[name].[chunkhash].js', | |
publicPath: 'public/' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.jsx?$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['babel-preset-env', 'react'] | |
} | |
} | |
}, | |
{ | |
test: /\.scss$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: ['css-loader', 'sass-loader'] | |
}) | |
} | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin({ | |
filename: '[name].[contenthash].css' | |
}), | |
new webpack.optimize.CommonsChunkPlugin({ | |
names: ['vendor', 'manifest'] | |
}), | |
new HtmlWebpackPlugin({ | |
filename: 'player/index.html', | |
chunks: ['vendor', 'player'], | |
template: 'src/player/index.html' | |
}), | |
new HtmlWebpackPlugin({ | |
filename: 'library/index.html', | |
chunks: ['vendor', 'library'], | |
template: 'src/library/index.html' | |
}) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment