-
Notifications
You must be signed in to change notification settings - Fork 202
/
webpack.config.js
54 lines (52 loc) · 1.46 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
// Webpack configuration for sphinx-book-theme
const { resolve } = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); // Compile our translation files
const { exec } = require("child_process");
exec("python src/sphinx_book_theme/_compile_translations.py");
// Paths for various assets (sources and destinations)
const staticPath = resolve(
__dirname,
"src/sphinx_book_theme/theme/sphinx_book_theme/static",
);
module.exports = {
mode: "production",
devtool: "source-map",
entry: {
"sphinx-book-theme": ["./src/sphinx_book_theme/assets/scripts/index.js"],
},
output: {
filename: "scripts/[name].js",
path: staticPath,
},
optimization: { minimizer: ["...", new CssMinimizerPlugin()] },
module: {
rules: [
{
test: /\.scss$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
// Interprets `@import` and `url()` like `import/require()` and will resolve them
{
loader: "css-loader",
options: {
url: false,
},
},
{
// Loads a SASS/SCSS file and compiles it to CSS
loader: "sass-loader",
options: {
sassOptions: { outputStyle: "expanded" },
},
},
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "styles/[name].css",
}),
],
};