-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
105 lines (103 loc) · 2.41 KB
/
Copy pathwebpack.config.js
File metadata and controls
105 lines (103 loc) · 2.41 KB
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
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const SRC_DIR = path.resolve(__dirname, 'src');
const DIST_DIR = path.resolve(__dirname, 'dist');
module.exports = {
context: SRC_DIR,
entry: {
app: ['babel-polyfill', './index.js']
},
output: {
path: DIST_DIR,
filename: '[name].js',
publicPath: ''
},
module: {
rules: [
{
test: /\.js$/,
include: SRC_DIR,
use: ['babel-loader']
},
{
test: /\.css$/,
include: SRC_DIR,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader']
})
},
{
test: /\.scss$/,
include: SRC_DIR,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'postcss-loader', 'sass-loader']
})
},
{
test: /\.(png|jpe?g)$/,
use: [
{
loader: 'url-loader',
options: {
name: '[name].[ext]',
outputPath: 'img/',
limit: 10000
}
},
'img-loader'
]
},
{
test: /\.woff(2)?(\?[a-z0-9#=&.]+)?$/,
use: [
{
loader: 'url-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
limit: 10000,
mimetype: 'application/font-woff'
}
}
]
}
]
},
resolve: {
extensions: ['.js'],
modules: [SRC_DIR, 'node_modules']
},
plugins: [
new CopyWebpackPlugin([{from: SRC_DIR, test: /\.(png|jpe?g)$/}]),
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
hash: false
}),
new ExtractTextPlugin({
filename: 'styles.css',
allChunks: true,
disable: false
}),
new webpack.optimize.UglifyJsPlugin()
],
devServer: {
contentBase: DIST_DIR,
publicPath: '',
historyApiFallback: true,
noInfo: false,
quiet: false,
stats: 'errors-only',
clientLogLevel: 'warning',
compress: true,
port: 8000
}
};