forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
99 lines (91 loc) · 2.2 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
var autoprefixer = require('autoprefixer');
var BundleTracker = require('webpack-bundle-tracker');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
var resolve = path.resolve.bind(path, __dirname);
var bundleTrackerPlugin = new BundleTracker({
filename: 'webpack-bundle.json'
});
var commonsChunkPlugin = new webpack.optimize.CommonsChunkPlugin({
names: 'vendor'
});
var occurenceOrderPlugin = new webpack.optimize.OccurenceOrderPlugin();
var extractTextPlugin = new ExtractTextPlugin('[name].[contenthash].css');
var providePlugin = new webpack.ProvidePlugin({
$: 'jquery',
'_': 'underscore',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'Tether': 'tether',
'window.Tether': 'tether'
});
var config = {
entry: {
category: './saleor/static/js/category.js',
dashboard: './saleor/static/js/dashboard.js',
storefront: './saleor/static/js/storefront.js',
vendor: [
'babel-es6-polyfill',
'bootstrap',
'jquery',
'jquery.cookie',
'react',
'react-relay'
]
},
output: {
path: resolve('saleor/static/assets/'),
filename: '[name].[chunkhash].js'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract([
'css?sourceMap',
'postcss',
'sass'
])
},
{
test: /\.(eot|otf|png|svg|jpg|ttf|woff|woff2)(\?v=[0-9.]+)?$/,
loader: 'url?name=[name].[hash].[ext]',
include: [
resolve('node_modules'),
resolve('saleor/static/fonts'),
resolve('saleor/static/images'),
resolve('saleor/static/img')
]
}
]
},
plugins: [
bundleTrackerPlugin,
commonsChunkPlugin,
extractTextPlugin,
occurenceOrderPlugin,
providePlugin
],
postcss: function() {
return [autoprefixer];
},
resolve: {
alias: {
'jquery': resolve('node_modules/jquery/dist/jquery.js')
}
},
sassLoader: {
sourceMap: true
}
};
module.exports = config;