Skip to content

Instantly share code, notes, and snippets.

@ahamedali95
Created August 4, 2019 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahamedali95/aaf8f82c45295e2defee3b1b87e5181b to your computer and use it in GitHub Desktop.
Save ahamedali95/aaf8f82c45295e2defee3b1b87e5181b to your computer and use it in GitHub Desktop.
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
//const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const srcDirectory = path.resolve(__dirname, '../src');
const buildDirectory = path.resolve(__dirname, '../build');
module.exports = {
entry: {
main: [path.join(srcDirectory, 'index.js')]
},
output: {
path: buildDirectory,
publicPath: ''
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: { presets: ['babel-preset-env', 'babel-preset-react'] }
}]
},
{
test: /\.html$/,
use: 'html-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|jpeg|svg|gif|woff|woff2|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: 'file-loader'
},
{
test: /\.css$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
}]
}
]
},
plugins: [
new CleanWebpackPlugin(['build'], {
root: process.cwd()
}),
new CopyWebpackPlugin([{
from: path.join(srcDirectory, 'assets/images'),
to: 'images'
}]),
new HtmlWebpackPlugin({
template: path.join(srcDirectory, 'public/index.html')
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment