forked from DinoChiesa/jwt-webtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
72 lines (60 loc) · 1.88 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
/* global process */
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const childProcess = require('child_process');
const packageVersion = require("./package.json").version;
const buildVersion = childProcess.execSync('git rev-list HEAD --count').toString();
function makeConfig(mode) {
let config = {
entry: ['./src/js/app.js', './src/scss/app.scss'],
target: 'web',
output: {
path: path.resolve('dist'),
filename: 'js/main.js'
},
module: {
rules: [
{
test: /\.(png|woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [ { loader: 'url-loader' } ]
},
{
test: /\.scss$/,
use: ['style-loader',
{
loader: MiniCssExtractPlugin.loader,
options: { }
},
'css-loader', 'sass-loader']
}]
},
plugins: [
new CopyPlugin({patterns:[
{ from: 'src/index.html', to: 'index.html' }
]}),
/* use jQuery as Global */
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery",
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css'
}),
new webpack.DefinePlugin({
BUILD_VERSION: JSON.stringify(packageVersion + '.' + buildVersion)
})
]
};
if (mode === 'development') {
config.devtool = 'source-map';
config.output.sourceMapFilename = '[file].map';
}
return config;
}
module.exports = (env, argv) => {
return makeConfig(argv.mode);
};