forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
118 lines (111 loc) · 2.92 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
var BundleTracker = require('webpack-bundle-tracker');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var resolve = path.resolve.bind(path, __dirname);
var extractCssPlugin;
var fileLoaderPath;
var output;
if (process.env.NODE_ENV === 'production') {
output = {
path: resolve('saleor/static/assets/'),
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
publicPath: process.env.STATIC_URL || '/static/assets/'
};
fileLoaderPath = 'file-loader?name=[name].[hash].[ext]';
extractCssPlugin = new MiniCssExtractPlugin({
filename: '[name].[chunkhash].css',
chunkFilename: '[id].[chunkhash].css'
});
} else {
output = {
path: resolve('saleor/static/assets/'),
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: '/static/assets/'
};
fileLoaderPath = 'file-loader?name=[name].[ext]';
extractCssPlugin = new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].css'
});
}
var bundleTrackerPlugin = new BundleTracker({
filename: 'webpack-bundle.json'
});
var providePlugin = new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'Popper': 'popper.js',
'query-string': 'query-string'
});
var config = {
entry: {
dashboard: './saleor/static/dashboard/js/dashboard.js',
document: './saleor/static/dashboard/js/document.js',
storefront: './saleor/static/js/storefront.js'
},
output: output,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
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,
extractCssPlugin,
providePlugin
],
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;