-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
109 lines (100 loc) · 2.58 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 CleanWebpackPlugin = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const paths = {
DIST: path.resolve(__dirname, 'dist'),
SRC: path.resolve(__dirname, 'src'),
JS: path.resolve(__dirname, 'src/js')
}
module.exports = {
entry: {
app: path.join(paths.JS, 'app.jsx'),
update: path.join(paths.JS, 'update.jsx')
},
output: {
path: paths.DIST,
filename: '[name].bundle.js'
}, devServer: {
inline: true,
contentBase: path.join(__dirname, 'dist'),
host: '0.0.0.0',
port: 8080,
disableHostCheck: true,
historyApiFallback: true,
},
plugins: [
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
template: path.join(paths.SRC, 'index.html')
}),
new HtmlWebpackPlugin({
template: path.join(paths.SRC, 'update.html'),
filename: "./update.html"
}),
new ExtractTextPlugin('style.bundle.css'),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
})
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
}, {
test: /\.(css)$/,
loader: ExtractTextPlugin.extract({ use: 'css-loader' })
}, {
test: /\.(png|jp(e*)g)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: 'images/[hash]-[name].[ext]'
}
}
]
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
// Limiting the size of the woff fonts breaks font-awesome ONLY for the extract text plugin
// loader: "url?limit=10000"
use: 'url-loader?limit=10000&mimetype=application/font-woff'
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'file-loader'
}, {
test: /\.(scss|sass)$/,
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader'
}, {
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('precss'),
require('autoprefixer')
]
}
}
}, {
loader: 'sass-loader'
}]
}
]
},
node: {
fs: 'empty'
},
resolve: {
extensions: ['.js', '.jsx']
}
}