-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
executable file
·116 lines (98 loc) · 2.45 KB
/
Copy pathwebpack.config.js
File metadata and controls
executable file
·116 lines (98 loc) · 2.45 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
106
107
108
109
110
111
112
113
114
115
116
var dev = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var node_dir = __dirname + '/node_modules';
var output_dir = __dirname +"/site/production"
var config = {
context: __dirname,
entry: "./site/js/index.js",
output: {
path: output_dir,
filename: 'index.js'
},
module: {
loaders: [
{
test: require.resolve('jquery'), loader: 'expose-loader?jQuery!expose-loader?$'
},
/* Uncomment this section if you're working with React/Babel
{
// loading JSX (aka Babel) into browser-friendly ES6
test: /\.js$/,
exclude: [
/(node_modules|bower_components)/,
'index.js',
],
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
*/
{
// loading sass asset files
test: /\.scss$/,
loaders: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [(dev? 'css-loader?sourceMap': 'css-loader'), (dev? 'sass-loader?sourceMap': 'sass-loader')]
})
},
{
// load external resources (ie Google fonts)
test: /.(png|woff(2)?|eot|ttf|svg|jpg|jpeg|gif)(\?[a-z0-9=\.]+)?$/,
loader: 'url-loader?limit=100000'
}
]
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
})
]
};
/**
* Development-only configuration values
**/
if( dev ){
// set compiled css location
config.plugins.push( new ExtractTextPlugin("index.css") );
// we want source maps
config.devtool = 'source-map';
/**
* Production-only configuration values
**/
}else{
// set our final output filename
config.output.filename = 'index.min.js';
// re-iterate our production value as a string (for ReactJS building)
config.plugins.push(
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify('production')
}
})
);
// remove all debug and console code
config.module.loaders.push(
{
test: /\.(js|jsx)$/,
loader: "webpack-strip?strip[]=console.log,strip[]=console.info,strip[]=debug"
}
);
// set compiled css location
config.plugins.push( new ExtractTextPlugin("index.min.css") );
// uglify our js, with no sourcemaps
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: true,
mangle: false,
sourceMap: false,
comments: false
})
);
}
// now export our collated config object
module.exports = config;