-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathwebpack.common.js
113 lines (110 loc) · 2.61 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
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
110
111
112
113
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const config = {
resolve: {
extensions: ['.js', '.jsx', '.json', '.mp3', '.ico']
},
entry: {
app: './src/scripts/app'
},
output: {
path: __dirname + '/public',
filename: '[name].[hash].js'
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
use: ['babel-loader', 'eslint-loader'],
},
{
test: /\.html$/,
use: ['raw-loader']
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
modules: {
mode: 'local',
localIdentName: '[local]',
},
importLoaders: true,
sourceMap: true,
localIdentName: '[local]',
}
}
]
},
{
test: /\.scss$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
modules: {
mode: 'local',
localIdentName: '[local]',
},
import: true,
importLoaders: true,
}
},
{ loader: 'sass-loader' }
]
},
{
test: /\.(eot|ttf|woff|woff2)$/,
loader: 'file-loader?name=fonts/[name].[ext]'
},
{
test: /\.(mp3)$/,
loader: 'file-loader?name=sounds/[name].[ext]'
},
{
test: /.*\.(gif|png|jpe?g|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=images/[name].[hash].[ext]',
'image-webpack?{optimizationLevel: 7, interlaced: false, pngquant:{quality: "65-90", speed: 4}, mozjpeg: {quality: 65}}'
]
}
]
},
plugins: [
new WebpackCleanupPlugin(),
new HtmlWebpackPlugin({
title: 'Calculator',
template: './src/index.html',
inject: 'body'
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'src/manifest.webmanifest', to: 'manifest.webmanifest'
},
{
from: 'src/.htaccess'
},
{
from: 'src/sounds', to: 'sounds'
},
{
from: 'src/browserconfig.xml', to: 'browserconfig.xml'
},
{
from: 'src/favicon.ico', to: 'favicon.ico'
},
{
from: 'src/images', to: 'images'
},
]
}),
]
};
module.exports = config;