forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
140 lines (129 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
var BundleTracker = require('webpack-bundle-tracker');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var FaviconsWebpackPlugin = require('favicons-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var resolve = path.resolve.bind(path, __dirname);
var extractTextPlugin;
var fileLoaderPath;
var output;
if (process.env.NODE_ENV === 'production') {
output = {
path: resolve('saleor/static/assets/'),
filename: '[name].[chunkhash].js',
publicPath: process.env.STATIC_URL || '/static/assets/'
};
fileLoaderPath = 'file-loader?name=[name].[hash].[ext]';
extractTextPlugin = new ExtractTextPlugin('[name].[contenthash].css');
} else {
output = {
path: resolve('saleor/static/assets/'),
filename: '[name].js',
publicPath: '/static/assets/'
};
fileLoaderPath = 'file-loader?name=[name].[ext]';
extractTextPlugin = new ExtractTextPlugin('[name].css');
}
var bundleTrackerPlugin = new BundleTracker({
filename: 'webpack-bundle.json'
});
var commonsChunkPlugin = new webpack.optimize.CommonsChunkPlugin({
names: 'vendor'
});
var occurenceOrderPlugin = new webpack.optimize.OccurrenceOrderPlugin();
var environmentPlugin = new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
});
var providePlugin = new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'Popper': 'popper.js'
});
var faviconsWebpackPlugin = new FaviconsWebpackPlugin({
logo: './saleor/static/images/favicon.svg',
prefix: 'favicons/',
title: "Saleor"
});
var config = {
entry: {
dashboard: './saleor/static/dashboard/js/dashboard.js',
storefront: './saleor/static/js/storefront.js',
document: './saleor/static/dashboard/scss/document.scss',
vendor: [
'babel-es6-polyfill',
'bootstrap',
'jquery',
'jquery.cookie',
'react'
]
},
output: output,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
'sourceMap': true
}
},
{
loader: 'postcss-loader',
options: {
'sourceMap': true,
'plugins': function () {
return [autoprefixer];
}
}
},
{
loader: 'sass-loader',
options: {
'sourceMap': true
}
}
]
})
},
{
test: /\.(eot|otf|png|svg|jpg|ttf|woff|woff2)(\?v=[0-9.]+)?$/,
loader: fileLoaderPath,
include: [
resolve('node_modules'),
resolve('saleor/static/fonts'),
resolve('saleor/static/images'),
resolve('saleor/static/dashboard/images')
]
}
]
},
plugins: [
bundleTrackerPlugin,
commonsChunkPlugin,
environmentPlugin,
extractTextPlugin,
occurenceOrderPlugin,
providePlugin,
faviconsWebpackPlugin
],
resolve: {
alias: {
'jquery': resolve('node_modules/jquery/dist/jquery.js'),
'react': resolve('node_modules/react/dist/react.min.js'),
'react-dom': resolve('node_modules/react-dom/dist/react-dom.min.js')
}
}
};
module.exports = config;