-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.common.js
78 lines (76 loc) · 1.72 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
75
76
77
78
'use strict'
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
entry: './app/scripts/index',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.json', '.jsx', '.css', '.html'],
alias: {
'morris.js': path.resolve(__dirname, 'node_modules/morris.js/morris.js'),
'~': path.resolve(__dirname, 'app')
}
},
target: 'web',
module: {
rules: [
{
test: /\.(ttf|eot|woff|woff2|svg)$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]'
}
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
include: [path.resolve(__dirname, 'app')],
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
new HtmlWebpackPlugin({
template: 'app/template.html'
}),
new MiniCssExtractPlugin({
filename: 'styles.css'
}),
new CopyWebpackPlugin({patterns: [
{ from: 'app/404.html' },
{ from: 'app/favicon.ico' },
{ from: 'app/robots.txt' },
{
context: 'app/config',
from: '*',
to: 'config/'
}
]})]
}