forked from openedx/credentials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
88 lines (87 loc) · 2.67 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
const BundleTracker = require('webpack-bundle-tracker');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');
const CssMinimizerPlugin = require('css-minimizer-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 MiniCssExtractPlugin({ filename: '[name]-[contenthash].css' }));
return plugins;
}
module.exports = {
mode: 'production',
cache: true,
context: __dirname,
entry: {
'base.style-ltr': './credentials/static/sass/main-ltr.scss',
'base.style-rtl': './credentials/static/sass/main-rtl.scss',
'override-style': './credentials/static/sass/overrides.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]-[contenthash].js',
libraryTarget: 'window',
publicPath: '/static/bundles/'
},
plugins: getPlugins(),
externals: {
gettext: 'gettext',
},
module: {
rules: [
{
test: /\.s?css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.woff2?$/,
// Inline small woff files and output them below font
use: [
{
loader: 'url-loader',
options: {
name: 'font/[name]-[contenthash].[ext]',
limit: 5000,
mimetype: 'font/woff2',
}
}
]
},
{
test: /\.(ttf|eot|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'font/[name]-[contenthash].[ext]'
}
}
]
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
},
],
},
optimization: {
minimizer: [
new CssMinimizerPlugin(),
],
},
resolve: {
modules: ['./node_modules'],
extensions: ['.css', '.js', '.jsx', '.scss'],
},
};