Skip to content

Instantly share code, notes, and snippets.

@adityaloshali
Created April 18, 2019 15:35
Show Gist options
  • Save adityaloshali/9b6a4713afa6fa2ab1d4c3f0b74ed2a9 to your computer and use it in GitHub Desktop.
Save adityaloshali/9b6a4713afa6fa2ab1d4c3f0b74ed2a9 to your computer and use it in GitHub Desktop.
Webpack Configuration
{
"presets": ["stage-1", "react", "es2015"],
"plugins": [
"syntax-dynamic-import",
"babel-plugin-transform-decorators-legacy",
"transform-object-rest-spread"
]
}
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const Clean = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, 'src/index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js'
},
devServer: {
port: 8082,
overlay: true,
stats: { colors: true },
host: '0.0.0.0',
disableHostCheck: true
},
// optimization: {
// splitChunks: {
// chunks: 'all'
// }
// },
module: {
rules: [
{ test: /\.(js)$/, exclude: /node_modules/, use: { loader: 'babel-loader' } },
{ test: /\.(scss|css)$/, loader: 'style-loader!css-loader!postcss-loader!sass-loader' },
{ test: /\.(jpg|png|svg)$/, loader: 'file-loader', options: { name: '[path][name].[hash].[ext]' } },
{
test: /\.(ttf|eot|woff|gif)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{
loader: 'file-loader'
}]
}
]
},
plugins: [
new CopyWebpackPlugin([
// Directory examples
{ from: 'src/html', to: '.', ignore: '*.html' }
]),
new HtmlWebpackPlugin({
inject: true,
filename: 'index.html',
template: path.resolve(__dirname, 'src/html/index.html')
}),
new Clean(['dist'])
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment