1
0
mirror of https://github.com/mgerb/react-starter synced 2026-01-08 08:02:49 +00:00
Files
react-starter/webpack.config.js
2018-11-08 20:05:56 -06:00

91 lines
2.0 KiB
JavaScript

const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
app: ['@babel/polyfill', './app/app.tsx'],
},
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].[hash].js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: ['babel-loader'],
},
{
test: /\.ts(x)?$/,
use: ['babel-loader', 'ts-loader'],
},
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: './.',
},
},
'css-loader',
'postcss-loader',
'sass-loader',
],
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: './.',
},
},
'css-loader',
],
},
{
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
use: [
{
loader: 'file-loader',
options: {
name: 'static/[name].[hash].[ext]',
publicPath: './.',
},
},
],
},
],
},
optimization: {
occurrenceOrder: true,
splitChunks: {
chunks: 'all',
},
},
plugins: [
new CleanWebpackPlugin(['./dist'], {
verbose: true,
}),
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
chunkFilename: '[id].css',
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.html',
}),
new webpack.HotModuleReplacementPlugin(),
new FaviconsWebpackPlugin('./favicon.png'),
],
};