forked from wbkd/webpack-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
54 lines (51 loc) · 1.23 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
'use strict';
const Path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const Webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const dest = Path.join(__dirname, '../dist');
module.exports = {
context: Path.join(__dirname, '../src'),
entry: [
Path.resolve(__dirname, './polyfills'),
Path.resolve(__dirname, '../src/scripts/index'),
],
output: {
path: dest,
filename: 'bundle.[hash].js',
},
plugins: [
new CleanWebpackPlugin([dest]),
new CopyWebpackPlugin([
{ from: Path.resolve(__dirname, '../public'), to: 'public' },
]),
new HtmlWebpackPlugin({
template: Path.resolve(__dirname, '../src/index.html'),
}),
],
resolve: {
alias: {
'~': Path.resolve(__dirname, '../src'),
},
},
module: {
rules: [
{
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
use: {
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
},
{
test: /\.(html)$/,
use: {
loader: 'html-loader',
},
},
],
},
};