Files
sphinx_rtd_theme/webpack.common.js
Anthony Johnson 006921a145 A few additions for migration to webpack
* Fix issues on paths in build and dev files
* Skip yarn to reduce tooling requirements
* Minify CSS assets in production
* Reduce imports on fonts, hardcode font pieces more. There are problems
  with the font family names. Roboto mixin brings in everything as
  `Roboto-Slab-Bold`, which won't match local font name of 'Roboto Slab'
* Fix the development instance more:
  * Add file watching on reST files
  * Execute build docs command after webpack build

Things I'm still not sure about:

- [ ] The actual JS output, I haven't vetted this yet
- [ ] If woff2 and woff are enough for fonts. The NPM packages are missing other formats
2019-07-17 23:37:55 -06:00

57 lines
1.4 KiB
JavaScript

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: './src/index.js',
output: {
filename: 'js/theme.js',
path: path.resolve(__dirname, 'sphinx_rtd_theme/static')
},
module: {
rules: [
{
test: require.resolve('./src/theme.js'),
use: 'imports-loader?this=>window'
},
{
test: /\.sass$/,
use: [{
loader: MiniCssExtractPlugin.loader
},
{
loader: "css-loader"
},
{
loader: "sass-loader?indentedSyntax",
options: {
includePaths: [
'node_modules/bourbon/app/assets/stylesheets',
'node_modules/bourbon-neat/app/assets/stylesheets',
'node_modules/font-awesome/scss',
'node_modules/wyrm/sass'
]
}
}]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]',
outputPath: 'fonts/',
publicPath: '../fonts/',
}
}]
}
]
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'css/theme.css'
})
],
};