-
Notifications
You must be signed in to change notification settings - Fork 361
/
webpack.config.js
109 lines (90 loc) · 2.97 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
105
106
107
108
109
const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const fs = require('fs');
const version = "4.0.2";
const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
let entries = {
'/js/dd.min.js': './src/js/index.js',
'/css/dd': './src/scss/style.scss'
};
let copyFolders = [
{ from: "./src/images", to: "./images" },
{ from: "./src/css/flags.css", to: "./css/flags.css" }
];
module.exports = {
entry: entries,
output: {
path:path.resolve(__dirname, './dist'),
filename:'[name]',
clean: true
},
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
// Load the CSS, set url = false to prevent following urls to fonts and images.
{ loader: "css-loader", options: { url: false, importLoaders: 1 } },
// Add browser prefixes and minify CSS.
{ loader: 'postcss-loader', options: { postcssOptions: { plugins: [autoprefixer(), cssnano()], }, }},
// Load the SCSS/SASS
{ loader: 'sass-loader' }
],
},
{
test:/\.jsx$/,
use:'babel-loader',
exclude:/node_modules/
}
],
},
plugins: [
new CleanWebpackPlugin(),
new FixStyleOnlyEntriesPlugin(),
new CopyPlugin({
patterns: copyFolders,
options: {
concurrency: 100,
},
}),
new webpack.BannerPlugin({
banner: `/**
* MSDropdown - dd.js
* @author: Marghoob Suleman
* @website: https://www.marghoobsuleman.com/
* @version: ${version}
* @date: ${new Date()}
* msDropdown is free web component: you can redistribute it and/or modify
* it under the terms of the either the MIT License or the Gnu General Public License (GPL) Version 2
*/`
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}, function () {
}),
{
apply: (compiler) => {
compiler.hooks.done.tap('everythingIsDone', (compilation) => {
for(let i in entries) {
let hasExnt = i.indexOf(".") > 0;
if(!hasExnt) {
fs.unlink(path.resolve(__dirname, './dist')+i, function () {
});
}
}
});
}
}
]
};