plugins.js
1.35 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
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const FriendlyErrorsPlugin = require("friendly-errors-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require('copy-webpack-plugin');
const path = require("path");
const resolve = path.resolve;
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV;
const copyPath = NODE_ENV == 'development' ? '../dist' : '../build';
const plugins = [
new HtmlWebpackPlugin({
filename: "index.html",
template: path.resolve(__dirname, "../index.html"),
}),
new CleanWebpackPlugin(),
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: ["You application is running here http://localhost:8080"],
notes: ["Some additionnal notes to be displayed upon successful compilation"],
},
onErrors: function(severity, errors) {},
clearConsole: true,
additionalFormatters: [],
additionalTransformers: [],
}),
new MiniCssExtractPlugin({
filename: "[name].[hash].css",
chunkFilename: "[id].css"
}),
new CopyPlugin([
{ from: resolve(__dirname, '../static'), to: resolve(__dirname, copyPath) },
]),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
Popper: 'popper.js/dist/umd/popper',
})
];
module.exports = plugins;