-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
104 lines (92 loc) · 2.8 KB
/
webpack.config.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
94
95
96
97
98
99
100
101
102
103
104
const MiniCSSExtractPlugin = require("mini-css-extract-plugin")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
const { VueLoaderPlugin } = require('vue-loader')
const path = require("path")
let mode = "development",
target = "web",
source_map = "source-map"
if (process.env.NODE_ENV === "production") {
mode = "production"
target = "browserslist"
source_map = "eval" // TODO:: better
}
module.exports = {
mode: mode,
target: target,
entry: {
es6: './src/es6entry.js',
react_entry: './src/react_js_entry.js',
homepage_block: './src/homepage_block.ts',
vue_app: './src/vue_entry.js',
},
output: {
assetModuleFilename: "images/[hash][ext][query]",
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
//clean: true,
},
plugins: [
new CleanWebpackPlugin(),
new VueLoaderPlugin(),
new MiniCSSExtractPlugin(),
new HtmlWebpackPlugin({
template: "./src/index.html"
}),
],
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg)$/i,
//type: "asset/inline", // in javascript file
//type: "asset/resource" //output folder
type: "asset" // for auto
},
{
test: /\.(s[ac]|c)ss$/i,
use: [
"vue-style-loader",
{
loader: MiniCSSExtractPlugin.loader,
options: { publicPath: "", esModule: false }
},
{
loader: "css-loader",
options: {
esModule: false
}
},
"sass-loader",
"postcss-loader"
]
},
{
test: /\.jsx?|\.ts$/,
exclude: /node_modules/,
use: { loader: "babel-loader" }
},
{
test: /\.vue$/,
exclude: /node_modules/,
loader: "vue-loader",
},
],
},
optimization: {
minimizer: [
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
// `...`,
new CssMinimizerPlugin(),
],
//minimize: true,// to minimize even in dev
},
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx", ".vue"],
alias: { vue: 'vue/dist/vue.js' },
},
devtool: source_map,
devServer: {
contentBase: "./dist",
hot: true
}
}