generated from poly-glot/vanilla-front-end-starter
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwebpack.js
executable file
·93 lines (86 loc) · 1.98 KB
/
webpack.js
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
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const PreloadWebpackPlugin = require('@vue/preload-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const plugins = [
new CleanWebpackPlugin({}),
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css'
}),
new HtmlWebpackPlugin({
template: 'public/index.html'
}),
new PreloadWebpackPlugin({
rel: 'preload',
include: 'all'
}),
new CopyWebpackPlugin({
patterns: [{
from: path.resolve(__dirname, 'public', 'assets'),
to: path.resolve(__dirname, 'dist', 'assets')
}]
})
]
if (process.env.BUNDLE_ANALYZE) {
plugins.push(new BundleAnalyzerPlugin())
}
module.exports = {
mode: "development",
entry: {
main: "./src/index.js",
},
output: {
filename: "[name].[contenthash].js",
path: path.resolve(__dirname, "dist")
},
devServer: {
historyApiFallback: true,
disableHostCheck: true,
stats: "minimal",
contentBase: path.join(__dirname, 'public'),
compress: true,
open: true,
hot: true
},
target: 'web',
resolve: {
fallback: {
"os": false
}
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: require("./.babelrc")
}
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
'css-loader',
'postcss-loader'
]
}
]
},
optimization: {
minimizer: [
new CssMinimizerPlugin(),
],
},
externals: {
firebase: 'firebase',
},
plugins
};