-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.development.js
More file actions
76 lines (75 loc) · 1.92 KB
/
webpack.development.js
File metadata and controls
76 lines (75 loc) · 1.92 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
const path = require('path');
const cors = require('cors');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const webpack = require('webpack');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
module.exports = {
mode: 'production',
module: {
rules: [
{
test: /\.css$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
],
},
],
},
optimization: {
minimize: false, // Disable minification
minimizer: [
new CssMinimizerPlugin({
include: /\.min\.css$/
}),
// Remove TerserPlugin to prevent JS minification
],
},
plugins: [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: 'css/fileselector.css'
}),
new HtmlWebpackPlugin({
filename: 'index.html',
inject: true,
template: path.resolve(__dirname, 'src', 'index.html'),
minify: {removeRedundantAttributes: false} // do not remove type="text"
}),
new webpack.DefinePlugin({
FS_VERSION: JSON.stringify(require("./package.json").version)
})
],
entry: {
'fileselector': path.resolve(__dirname, './src/js/fileselector.js'),
},
devServer: {
client: {
overlay: false,
},
static: [{
directory: path.join(__dirname, 'dist'),
},
{
directory: path.join(__dirname, './src/js/presets'),
}],
setupMiddlewares: (middlewares, devServer) => {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}
devServer.app.use(cors());
return middlewares;
},
},
output: {
filename: '[name].js', // Serve unminified JS
path: path.resolve(__dirname, 'dist'),
},
};