-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
88 lines (85 loc) · 2.11 KB
/
webpack.config.js
File metadata and controls
88 lines (85 loc) · 2.11 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
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var BUILD_DIR = path.resolve(__dirname, 'build');
var APP_DIR = path.resolve(__dirname, 'src');
var config = {
entry: {
vendor: [
'react', 'react-dom', 'prop-types',
],
main: path.resolve(APP_DIR, 'index.jsx'),
styles: path.resolve(APP_DIR, 'sass/css.js'),
},
output: {
path: BUILD_DIR,
filename: '[name].[hash].bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(APP_DIR, 'index.html')
}),
new ExtractTextPlugin({
filename: 'styles.[hash].css'
}),
new CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.[hash].js',
}),
new CleanWebpackPlugin([
BUILD_DIR,
], {
exclude: ['.gitkeep'],
verbose: true,
dry: false,
watch: false,
allowExternal: false,
}),
],
resolve: {
extensions: ['.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
include: APP_DIR,
loader: 'babel-loader',
query: {
presets: ['env', 'stage-2', 'react'],
plugins: [
'transform-object-rest-spread', 'transform-class-properties',
],
},
},
{
test: /\.html$/,
include: APP_DIR,
loader: 'html-loader'
},
{
test: /\.scss$/,
include: APP_DIR,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
{
loader: 'postcss-loader',
options: { plugins: [require('autoprefixer')({ browsers: ['last 2 versions'] })] },
},
'sass-loader'
]
})
},
{
test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: "file-loader"
}
]
},
};
module.exports = config;