JSFiddle - React, Tailwind, and code Playground
by shurikation
JavaScript
const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
app: [
'./src/index.js',
'./src/style.scss'
]
},
output: {
// filename: '[name].bundle.js',
// chunkFilename: '[name].bundle.js',
// path: path.resolve(__dirname, 'dist'),
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
devServer: {
contentBase: './dist',
stats: 'errors-only'
},
optimization: {
minimize: false,
minimizer: [
new TerserJSPlugin({
test: /\.js(\?.*)?$/i,
}),
new OptimizeCSSAssetsPlugin({})
],
},
plugins: [
new HTMLWebpackPlugin({
template: './src/index.html'
}),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
output: path.resolve(__dirname, 'src')
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'src', 'components'),
to: path.resolve(__dirname, 'dist', 'components'),
globOptions: {
ignore: [
'**/*.scss',
],
},
},
],
})
],
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.s[ac]ss$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|jpe?g|gif)$/i,
use: [
{
loader: 'file-loader',
options: {
name:...