-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
executable file
·74 lines (71 loc) · 1.44 KB
/
webpack.common.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
var Webpack = require('webpack');
var path = require('path');
var nodeModulesPath = path.resolve(__dirname, 'node_modules');
var buildPath = path.resolve(__dirname, 'dist');
var mainPath = path.resolve(__dirname, 'src', 'index.js');
const CleanWebPackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
var config = {
entry: {
app: ['react-hot-loader/patch', mainPath]
},
plugins: [
// Clears the build folder (dist) before each build
new CleanWebPackPlugin([buildPath]),
// Generates new index.html file with correct filename
new HtmlWebpackPlugin({
title: 'Viper Visualizer',
template: 'src/index.tpl.html',
filename: 'index.html'
}),
new Webpack.NamedModulesPlugin(),
new Webpack.HotModuleReplacementPlugin()
],
output: {
filename: '[name].bundle.[hash].js',
path: buildPath,
publicPath: '/'
},
module: {
rules: [
// Javascript
{
test: /\.js$/,
exclude: [nodeModulesPath],
use: [
'babel-loader'
]
},
// HTML
{
test: /\.html$/,
use: ['html-loader']
},
// Less
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader'
]
},
// Fonts
{
test: /\.(woff|woff2)$/,
use: ['file-loader']
},
// Images
{
test: /\.(jpeg|jpg|png|svg|gif)$/,
use: ['file-loader']
},
// Json
{
test: /\.json$/,
use: ['json-loader']
}
]
}
};
module.exports = config;