-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
69 lines (68 loc) · 2.12 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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssPlugin = require('optimize-css-assets-webpack-plugin');
const BundleTracker = require('webpack-bundle-tracker');
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');
module.exports = {
context: __dirname,
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
optimization: {
minimize: process.env.NODE_ENV === 'production',
minimizer: [
new TerserPlugin({
test: /\.js($|\?)/i
}),
new OptimizeCssPlugin()
]
},
entry: {
blogPost: path.resolve('assets', 'js', 'blog-post.js'),
facebookSdk: path.resolve('assets', 'js', 'fb_sdk.js'),
portfolio: path.resolve('assets', 'js', 'portfolio.js'),
twitterSdk: path.resolve('assets', 'js', 'twitter_sdk.js'),
main: path.resolve('assets', 'js', 'index.js')
},
output: {
path: path.resolve('assets', 'dist'),
filename: '[name]-bundle-[hash:6].js'
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /\.s?css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|eot|ttf)$/,
loader: 'file-loader'
},
{
test: /\.js$/,
use: ['babel-loader']
}
]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery:'jquery'
}),
new MiniCssExtractPlugin('[name]-[hash:6].css'),
new BundleTracker({filename: './webpack-stats.json'})
]
};