Created
August 4, 2019 02:28
-
-
Save ahamedali95/aaf8f82c45295e2defee3b1b87e5181b to your computer and use it in GitHub Desktop.
This file contains 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 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