-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (94 loc) · 2.52 KB
/
Copy pathwebpack.config.js
File metadata and controls
100 lines (94 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const path = require('path');
const webpack = require('webpack');
/*
* HTML Webpack Plugin ~ This is a webpack plugin that simplifies creation of HTML files to serve your
* webpack bundles. This is especially useful for webpack bundles that include a
* hash in the filename which changes every compilation. You can either let the
* plugin generate an HTML file for you, supply your own template using lodash
* templates or use your own loader.
*
* https://www.npmjs.com/package/html-webpack-plugin
*
*/
const HtmlWebpackPlugin = require('html-webpack-plugin');
/*
* Mini Css Extract Plugin ~ This allows your app to
* use css modules that will be moved into a separate CSS file instead of inside
* one of your module entries!
*
* https://github.com/webpack-contrib/mini-css-extract-plugin
*
*/
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
/*
* Terser Webpack Plugin ~ A JavaScript parser and mangler/compressor toolkit for ES6+.
* This minifies your app in order to load faster and run less javascript.
*
* https://github.com/webpack-contrib/terser-webpack-plugin
*
*/
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
entry: {
styles: './src/css/main.scss',
app: './src/js/app.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
mode: process.env.NODE_ENV,
devServer: {
contentBase: [
path.join(__dirname, 'dist'),
path.join(__dirname, 'src/html'),
],
liveReload: true,
port: 8800,
watchContentBase: true,
},
devtool:
process.env.NODE_ENV === 'development' ? 'eval-source-map' : 'source-map',
plugins: [
new webpack.ProgressPlugin(),
new MiniCssExtractPlugin({ filename: '[name].css' }),
new HtmlWebpackPlugin({
title: 'Tailwind CSS Playground',
template: './src/html/index.html',
}),
],
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /.(css|s[ac]ss)$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: true,
},
},
{
loader: 'postcss-loader',
},
{
loader: 'sass-loader',
},
],
},
],
},
optimization: {
minimize: process.env.NODE_ENV === 'production',
minimizer: [new TerserPlugin()],
},
};