-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
68 lines (67 loc) · 2.32 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
const { IN_DIST, IN_SRC } = require('./webpack.paths.js');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = {
mode: 'none', // reset mode and don't perform any optimizations
context: IN_SRC(), // all configurations are relative to be inside IN_SRC()
resolve: {
extensions: ['.js', '.json', '.jsx'] // allows us to drop file extensions when importing
},
entry: {
app: './index.js' // start building dependency stree from here
},
output: {
path: IN_DIST() // output all files here
},
module: {
rules: [
{
test: /\.jsx?$/, // transpile .js/.jsx syntax through babel first
exclude: /node_modules/, // don't run node packages through babel (optimization)
use: [
{
loader: "babel-loader"
}
]
},
{
test: /\.(png|svg|jpg|gif)$/, // handle images
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/images' // output in specific folder
}
},
{
loader: "image-webpack-loader",
options: {
bypassOnDebug: true
}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/, // handle fonts
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/fonts' // output in specific folder
}
}
]
}
]
},
plugins: [
new CleanWebpackPlugin([ IN_DIST() ]), // Always clean DIST folder when running webpack
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin({
template: IN_SRC('/index.html') // Use index.html template
})
],
};