forked from edly-io/credentials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
103 lines (88 loc) · 3.16 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
const BundleTracker = require('webpack-bundle-tracker');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const isDevstack = (process.env.DJANGO_SETTINGS_MODULE === 'credentials.settings.devstack');
// Conditionally add all of the plugins
function getPlugins() {
const plugins = [];
plugins.push(new BundleTracker({ filename: './webpack-stats.json' }));
plugins.push(new ExtractTextPlugin('[name]-[hash].css'));
// Only load this plugin in devstack since we are not sure if
// caching could cause issues in production builds later on
if (isDevstack) {
plugins.push(new HardSourceWebpackPlugin());
}
return plugins;
}
module.exports = {
cache: true,
context: __dirname,
entry: {
'base.style-ltr': './credentials/static/sass/main-ltr.scss',
'base.style-rtl': './credentials/static/sass/main-rtl.scss',
'openedx.certificate.style-ltr': './credentials/apps/credentials_theme_openedx/static/sass/certificate-ltr.scss',
'openedx.certificate.style-rtl': './credentials/apps/credentials_theme_openedx/static/sass/certificate-rtl.scss',
'sharing': './credentials/static/js/sharing.js',
'analytics': './credentials/static/js/analytics.js',
'records': './credentials/static/components/RecordsFactory.jsx',
'programs': './credentials/static/components/ProgramRecordFactory.jsx',
'masquerading': './credentials/static/components/MasqueradeBannerFactory.jsx',
},
output: {
path: path.resolve('./credentials/static/bundles/'),
filename: '[name]-[hash].js',
libraryTarget: 'window',
},
plugins: getPlugins(),
externals: {
gettext: 'gettext',
},
module: {
rules: [
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
minimize: true
}
},
{
loader: 'sass-loader'
}
]
})
},
{
test: /\.woff2?$/,
// Inline small woff files and output them below font
loader: 'url-loader',
query: {
name: 'font/[name]-[hash].[ext]',
limit: 5000,
mimetype: 'application/font-woff'
}
},
{
test: /\.(ttf|eot|svg)$/,
loader: 'file-loader',
query: {
name: 'font/[name]-[hash].[ext]'
}
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
]
},
resolve: {
modules: ['./node_modules'],
extensions: ['.css', '.js', '.jsx', '.scss'],
}
};