-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
executable file
·116 lines (115 loc) · 3.49 KB
/
webpack.config.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
114
115
116
const path = require('path');
const webpack = require('webpack');
const config = require('./config.js');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
module.exports = {
entry: {
main : "./src/index",
home : "./src/components/templates/home/index",
single : "./src/components/templates/single/index",
page : "./src/components/templates/page/index",
default : "./src/components/templates/default/index"
},
output: {
path: path.resolve(__dirname, "dist"),
filename: '[name].bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
}
]
})
},
{
test: /\.svg$/,
include: path.resolve( __dirname, "src/icons" ),
loaders: [
'svg-sprite-loader?' + JSON.stringify({
name: '[name]',
prefixize: true
}),
'svgo-loader?' + JSON.stringify({
plugins: [
{ removeTitle: true },
{ convertPathData: false },
{ removeUselessStrokeAndFill: true }
]
})
]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: {
loader: 'file-loader',
options: {
exclude: path.resolve( __dirname, "src/icons" )
}
}
}
],
},
devServer: {
historyApiFallback: true,
compress: true,
port: 9000,
https: config.url.indexOf('https') > -1 ? true : false,
publicPath: config.fullPath,
proxy: {
'*': {
'target': config.url,
'secure': false
},
'/': {
target: config.url,
secure: false
}
},
},
plugins: [
new ExtractTextPlugin({
filename: (getPath) => {
return getPath('css/[name].css').replace('css/js', 'css');
},
allChunks: true
}),
new BrowserSyncPlugin( {
proxy: config.url,
files: [
'**/*.php'
],
reloadDelay: 0
}
),
/*new webpack.optimize.CommonsChunkPlugin({
name: 'common'
})*/
]
}