forked from executablebooks/sphinx-book-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
59 lines (56 loc) · 1.62 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
// Webpack configuration for sphinx-book-theme
const { resolve } = require("path");
const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const dedent = require("dedent");
// 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: {
minimize: true,
minimizer: [
new TerserPlugin({ sourceMap: true }),
new OptimizeCssAssetsPlugin({}),
],
},
module: {
rules: [
{
test: /\.scss$/,
use: [
{
loader: "file-loader", // using the string as content, emits a file into the output directory.
options: {
name: "styles/sphinx-book-theme.css", // the output file name
},
},
{
loader: "extract-loader", // extracts the css from the source js file into a string
},
{
// Use the css-loader with url()-inlining turned off.
loader: "css-loader?-url", // loads the css into the main js
},
{
loader: "sass-loader", // turns scss into css
},
],
},
],
},
};