forked from openedx/credentials-themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
94 lines (90 loc) · 2.42 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
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require('webpack');
function generateBaseConfig(theme) {
let config = {
mode: 'production',
cache: true,
context: path.resolve(`./edx_credentials_themes/static/${theme}`),
entry: {
[`${theme}.base.style-ltr`]: './base/sass/main-ltr.scss',
[`${theme}.base.style-rtl`]: './base/sass/main-rtl.scss',
[`${theme}.certificate.style-ltr`]: './certificates/sass/certificate-ltr.scss',
[`${theme}.certificate.style-rtl`]: './certificates/sass/certificate-rtl.scss',
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css'
}),
],
output: {
path: path.resolve(`./edx_credentials_themes/static/${theme}/`),
},
stats: {
errors: true,
errorDetails: true,
},
optimization: {
minimize: true,
},
module: {
rules: [
{
test: /\.s?css$/,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: [
path.join(__dirname, 'node_modules'),
],
},
},
},
]
},
{
test: /\.woff2?$/,
// Inline small woff files and output them below font
use: [
{
loader: 'url-loader',
options: {
name: 'fonts/[name]-[contenthash].[ext]',
limit: 5000,
mimetype: 'font/woff2',
}
}
]
},
{
test: /\.(ttf|otf|eot|svg|)(\?[a-z0-9]+)?$/,
use: [{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
publicPath: '../'
}
}]
}
]
},
resolve: {
modules: ['./node_modules'],
extensions: ['.css', '.js', '.scss']
}
};
return config
}
// Change back to ['edx.org'].map(generateCertificateConfig) once we add in
// the need to style Program certificates
let targets = [];
let baseTargets = ['edx.org'].map(generateBaseConfig);
for (configIndex in baseTargets) {
targets.push(baseTargets[configIndex]);
}
module.exports = targets;