-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
103 lines (90 loc) · 2.52 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
var webpack = require('webpack'),
htmlGenerator = require('html-webpack-plugin'),
copyPlugin = require('copy-webpack-plugin')
path = require('path'),
CleanWebpackPlugin = require('clean-webpack-plugin'),
ExtractTextPlugin = require("extract-text-webpack-plugin");
var source = path.join(__dirname, 'src')
var build = path.join(__dirname, 'build')
module.exports = {
target: 'web',
entry: {
app: [
path.join(source, 'js/app.js')
],
// vendor: [
// 'react', 'react-dom', 'react-burger-menu', 'radium'
// ]
},
resolve: {
modulesDirectories: [
'node_modules',
'bower_components',
source
]
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
plugins: ['babel-plugin-transform-decorators-legacy', 'babel-plugin-transform-class-properties', 'babel-plugin-react-html-attrs'],
presets: ['stage-2','es2015', 'react']
}
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({fallbackLoader: 'style', loader: 'css-loader!sass'})
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({fallbackLoader: 'style', loader: 'css-loader'})
},
{
test: /template\.jade/,
exclude: /(node_modules|bower_components|)/,
loader: 'raw!jade-html'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
loader: 'url?limit=25000',
include: source
}
]
},
output: {
path: build,
publicPath: '/wp-content/themes/cids/',
filename: 'js/[name]-[hash].js',
chunkFilename: 'js/chunks/[name]-[id].js'
},
plugins: [
new CleanWebpackPlugin([path.join(build, '/*')], {'verbose' : true}),
new htmlGenerator({
inject: true,
template: 'jade!src/index.jade',
filename: 'index.php'
}),
new copyPlugin([
{from: path.join(source, 'functions.php')},
{from: path.join(source, 'style.css')},
// Copy Images
{from: path.join(source, 'img/'), to: 'img/'}
]),
new ExtractTextPlugin({
filename: "[name]-[hash].css",
inject: 'head',
template: 'jade!src/index.jade'
}),
// new webpack.optimize.CommonsChunkPlugin({name: "vendor", filename: "vendor.bundle.js"}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
]
}