mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
successful build with webpack
This commit is contained in:
parent
020f5a4bd0
commit
beca6ea743
189
Gruntfile.js
189
Gruntfile.js
@ -1,189 +0,0 @@
|
||||
module.exports = function(grunt) {
|
||||
|
||||
// load all grunt tasks
|
||||
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
|
||||
|
||||
grunt.initConfig({
|
||||
// Read package.json
|
||||
pkg: grunt.file.readJSON("package.json"),
|
||||
|
||||
open : {
|
||||
dev: {
|
||||
path: 'http://localhost:1919'
|
||||
}
|
||||
},
|
||||
|
||||
connect: {
|
||||
server: {
|
||||
options: {
|
||||
port: 1919,
|
||||
base: 'docs/build',
|
||||
livereload: true
|
||||
}
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
fonts: {
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
flatten: true,
|
||||
src: ['bower_components/font-awesome/fonts/*'],
|
||||
dest: 'sphinx_rtd_theme/static/fonts/',
|
||||
filter: 'isFile'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
flatten: true,
|
||||
src: ['fonts/Lato/*'],
|
||||
dest: 'sphinx_rtd_theme/static/fonts/Lato',
|
||||
filter: 'isFile'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
flatten: true,
|
||||
src: ['fonts/RobotoSlab/*'],
|
||||
dest: 'sphinx_rtd_theme/static/fonts/RobotoSlab/',
|
||||
filter: 'isFile'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
sass: {
|
||||
dev: {
|
||||
options: {
|
||||
style: 'expanded',
|
||||
loadPath: ['bower_components/bourbon/dist', 'bower_components/neat/app/assets/stylesheets', 'bower_components/font-awesome/scss', 'bower_components/wyrm/sass']
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'sass',
|
||||
src: ['*.sass'],
|
||||
dest: 'sphinx_rtd_theme/static/css',
|
||||
ext: '.css'
|
||||
}]
|
||||
},
|
||||
build: {
|
||||
options: {
|
||||
style: 'compressed',
|
||||
sourcemap: 'none',
|
||||
loadPath: ['bower_components/bourbon/dist', 'bower_components/neat/app/assets/stylesheets', 'bower_components/font-awesome/scss', 'bower_components/wyrm/sass']
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'sass',
|
||||
src: ['*.sass'],
|
||||
dest: 'sphinx_rtd_theme/static/css',
|
||||
ext: '.css'
|
||||
}]
|
||||
}
|
||||
},
|
||||
|
||||
browserify: {
|
||||
dev: {
|
||||
options: {
|
||||
external: ['jquery'],
|
||||
alias: {
|
||||
'sphinx-rtd-theme': './js/theme.js'
|
||||
}
|
||||
},
|
||||
src: ['js/*.js'],
|
||||
dest: 'sphinx_rtd_theme/static/js/theme.js'
|
||||
},
|
||||
build: {
|
||||
options: {
|
||||
external: ['jquery'],
|
||||
alias: {
|
||||
'sphinx-rtd-theme': './js/theme.js'
|
||||
}
|
||||
},
|
||||
src: ['js/*.js'],
|
||||
dest: 'sphinx_rtd_theme/static/js/theme.js'
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
dist: {
|
||||
options: {
|
||||
sourceMap: false,
|
||||
mangle: {
|
||||
reserved: ['jQuery'] // Leave 'jQuery' identifier unchanged
|
||||
},
|
||||
ie8: true // compliance with IE 6-8 quirks
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
src: ['sphinx_rtd_theme/static/js/*.js', '!sphinx_rtd_theme/static/js/*.min.js'],
|
||||
dest: 'sphinx_rtd_theme/static/js/',
|
||||
rename: function (dst, src) {
|
||||
// Use unminified file name for minified file
|
||||
return src;
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
usebanner: {
|
||||
dist: {
|
||||
options: {
|
||||
position: 'top',
|
||||
banner: '/* <%= pkg.name %> version <%= pkg.version %> | MIT license */\n' +
|
||||
'/* Built <%= grunt.template.today("yyyymmdd HH:mm") %> */',
|
||||
linebreak: true
|
||||
},
|
||||
files: {
|
||||
src: [ 'sphinx_rtd_theme/static/js/theme.js', 'sphinx_rtd_theme/static/css/theme.css' ]
|
||||
}
|
||||
}
|
||||
},
|
||||
exec: {
|
||||
bower_update: {
|
||||
cmd: 'bower update'
|
||||
},
|
||||
build_sphinx: {
|
||||
cmd: 'sphinx-build docs/ docs/build'
|
||||
}
|
||||
},
|
||||
clean: {
|
||||
build: ["docs/build"],
|
||||
fonts: ["sphinx_rtd_theme/static/fonts"],
|
||||
css: ["sphinx_rtd_theme/static/css"],
|
||||
js: ["sphinx_rtd_theme/static/js/*", "!sphinx_rtd_theme/static/js/modernizr.min.js"]
|
||||
},
|
||||
|
||||
watch: {
|
||||
/* Compile sass changes into theme directory */
|
||||
sass: {
|
||||
files: ['sass/*.sass', 'bower_components/**/*.sass'],
|
||||
tasks: ['sass:dev']
|
||||
},
|
||||
/* Changes in theme dir rebuild sphinx */
|
||||
sphinx: {
|
||||
files: ['sphinx_rtd_theme/**/*', 'README.rst', 'docs/**/*.rst', 'docs/**/*.py'],
|
||||
tasks: ['clean:build','exec:build_sphinx']
|
||||
},
|
||||
/* JavaScript */
|
||||
browserify: {
|
||||
files: ['js/*.js'],
|
||||
tasks: ['browserify:dev']
|
||||
},
|
||||
/* live-reload the docs if sphinx re-builds */
|
||||
livereload: {
|
||||
files: ['docs/build/**/*'],
|
||||
options: { livereload: true }
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-exec');
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-sass');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-open');
|
||||
grunt.loadNpmTasks('grunt-browserify');
|
||||
|
||||
grunt.registerTask('default', ['exec:bower_update','clean','copy:fonts','sass:dev','browserify:dev','usebanner','exec:build_sphinx','connect','open','watch']);
|
||||
grunt.registerTask('build', ['exec:bower_update','clean','copy:fonts','sass:build','browserify:build','uglify','usebanner','exec:build_sphinx']);
|
||||
}
|
37
bower.json
37
bower.json
@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "sphinx-rtd-theme",
|
||||
"version": "0.4.3",
|
||||
"homepage": "https://github.com/rtfd/sphinx_rtd_theme",
|
||||
"authors": [
|
||||
"Dave Snider, Read the Docs, Inc. & contributors <dev@readthedocs.org>"
|
||||
],
|
||||
"description": "Sphinx theme for readthedocs.org.",
|
||||
"license": "MIT",
|
||||
"main": [
|
||||
"js/theme.js"
|
||||
],
|
||||
"ignore": [
|
||||
"docs",
|
||||
".gitignore",
|
||||
".DS_Store",
|
||||
".sass-cache*",
|
||||
".bowerrc",
|
||||
"bower.json",
|
||||
"package.json",
|
||||
"Gruntfile.js",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests",
|
||||
"src"
|
||||
],
|
||||
"devDependencies": {
|
||||
"wyrm": "~1.0.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"font-awesome": "~4.7"
|
||||
},
|
||||
"resolutions": {
|
||||
"font-awesome": "~4.7"
|
||||
}
|
||||
}
|
41
package.json
41
package.json
@ -3,21 +3,32 @@
|
||||
"main": "js/theme.js",
|
||||
"version": "0.4.3",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"bower": "^1.8.4",
|
||||
"scripts": {
|
||||
"start": "yarn webpack-dev-server --open --config webpack.dev.js",
|
||||
"build": "yarn webpack --config webpack.prod.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"bourbon": "~4.3",
|
||||
"bourbon-neat": "~1.7",
|
||||
"browserify": "^13.0.0",
|
||||
"connect-livereload": "~0.6.0",
|
||||
"grunt": "~1.0.1",
|
||||
"grunt-banner": "^0.6.0",
|
||||
"grunt-browserify": "^5.0.0",
|
||||
"grunt-contrib-clean": "^1.0.0",
|
||||
"grunt-contrib-connect": "^1.0.2",
|
||||
"grunt-contrib-copy": "~1.0.0",
|
||||
"grunt-contrib-sass": "~1.0.0",
|
||||
"grunt-contrib-uglify": "~3.3.0",
|
||||
"grunt-contrib-watch": "~1.0.0",
|
||||
"grunt-exec": "~1.0.1",
|
||||
"grunt-open": "0.2.3",
|
||||
"matchdep": "~1.0.1"
|
||||
"css-loader": "^2.1.1",
|
||||
"file-loader": "^3.0.1",
|
||||
"font-awesome": "^4.7.0",
|
||||
"imports-loader": "^0.8.0",
|
||||
"jquery": "^3.4.1",
|
||||
"lato-font": "^3.0.0",
|
||||
"matchdep": "~1.0.1",
|
||||
"mini-css-extract-plugin": "^0.6.0",
|
||||
"node-sass": "^4.12.0",
|
||||
"roboto-fontface": "^0.10.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"webpack": "^4.30.0",
|
||||
"webpack-cli": "^3.3.1",
|
||||
"webpack-merge": "^4.2.1",
|
||||
"wyrm": "^1.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"webpack-dev-server": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
@font-face
|
||||
font-family: 'Lato'
|
||||
src: url('../fonts/Lato/lato-regular.eot')
|
||||
src: url('../fonts/Lato/lato-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/Lato/lato-regular.woff2') format('woff2'), url('../fonts/Lato/lato-regular.woff') format('woff'), url('../fonts/Lato/lato-regular.ttf') format('truetype')
|
||||
font-weight: 400
|
||||
font-style: normal
|
||||
font-display: $font-display
|
||||
|
||||
@font-face
|
||||
font-family: 'Lato'
|
||||
src: url('../fonts/Lato/lato-bold.eot')
|
||||
src: url('../fonts/Lato/lato-bold.eot?#iefix') format('embedded-opentype'), url('../fonts/Lato/lato-bold.woff2') format('woff2'), url('../fonts/Lato/lato-bold.woff') format('woff'), url('../fonts/Lato/lato-bold.ttf') format('truetype')
|
||||
font-weight: 700
|
||||
font-style: normal
|
||||
font-display: $font-display
|
||||
|
||||
@font-face
|
||||
font-family: 'Lato'
|
||||
src: url('../fonts/Lato/lato-bolditalic.eot')
|
||||
src: url('../fonts/Lato/lato-bolditalic.eot?#iefix') format('embedded-opentype'), url('../fonts/Lato/lato-bolditalic.woff2') format('woff2'), url('../fonts/Lato/lato-bolditalic.woff') format('woff'), url('../fonts/Lato/lato-bolditalic.ttf') format('truetype')
|
||||
font-weight: 700
|
||||
font-style: italic
|
||||
font-display: $font-display
|
||||
|
||||
@font-face
|
||||
font-family: 'Lato'
|
||||
src: url('../fonts/Lato/lato-italic.eot')
|
||||
src: url('../fonts/Lato/lato-italic.eot?#iefix') format('embedded-opentype'), url('../fonts/Lato/lato-italic.woff2') format('woff2'), url('../fonts/Lato/lato-italic.woff') format('woff'), url('../fonts/Lato/lato-italic.ttf') format('truetype')
|
||||
font-weight: 400
|
||||
font-style: italic
|
||||
font-display: $font-display
|
||||
|
||||
@font-face
|
||||
font-family: 'Roboto Slab'
|
||||
font-style: normal
|
||||
font-weight: 400
|
||||
src: url('../fonts/RobotoSlab/roboto-slab.eot')
|
||||
src: url('../fonts/RobotoSlab/roboto-slab-v7-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/RobotoSlab/roboto-slab-v7-regular.woff2') format('woff2'), url('../fonts/RobotoSlab/roboto-slab-v7-regular.woff') format('woff'), url('../fonts/RobotoSlab/roboto-slab-v7-regular.ttf') format('truetype')
|
||||
font-display: $font-display
|
||||
|
||||
@font-face
|
||||
font-family: 'Roboto Slab'
|
||||
font-style: normal
|
||||
font-weight: 700
|
||||
src: url('../fonts/RobotoSlab/roboto-slab-v7-bold.eot')
|
||||
src: url('../fonts/RobotoSlab/roboto-slab-v7-bold.eot?#iefix') format('embedded-opentype'), url('../fonts/RobotoSlab/roboto-slab-v7-bold.woff2') format('woff2'), url('../fonts/RobotoSlab/roboto-slab-v7-bold.woff') format('woff'), url('../fonts/RobotoSlab/roboto-slab-v7-bold.ttf') format('truetype')
|
||||
font-display: $font-display
|
3
src/index.js
Normal file
3
src/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import './sass/theme.sass';
|
||||
import './sass/badge_only.sass';
|
||||
import './theme.js';
|
@ -1,6 +1,6 @@
|
||||
// Slimmer version of FA for use on the badge_only.sass file.
|
||||
|
||||
+font-face(FontAwesome, '#{$font-awesome-dir}fontawesome-webfont')
|
||||
+font-face(FontAwesome, '#{$fa-font-path}/fontawesome-webfont')
|
||||
|
||||
.fa:before
|
||||
display: inline-block
|
6
src/sass/_theme_font_local.sass
Normal file
6
src/sass/_theme_font_local.sass
Normal file
@ -0,0 +1,6 @@
|
||||
$lato-font-path: "~lato-font/fonts"
|
||||
$lato-variants: ('normal': 400, 'bold': 700)
|
||||
@import ~lato-font/scss/lato-font
|
||||
|
||||
$roboto-font-path: "~roboto-fontface/fonts"
|
||||
@import ~roboto-fontface/css/roboto-slab/sass/roboto-slab-fontface
|
@ -2,7 +2,7 @@
|
||||
// that are set in wyrm_core/wy_variables.sass. You'll find wyrm in bower_components if you're looking
|
||||
// for a reference.
|
||||
|
||||
$font-awesome-dir: "../fonts/"
|
||||
$fa-font-path: "~font-awesome/fonts"
|
||||
$static-img: "../img/"
|
||||
|
||||
$nav-content-width: 800px
|
@ -8,8 +8,8 @@ $border-box-sizing: false !default
|
||||
|
||||
@import wyrm_core/wy_variables
|
||||
@import theme_variables
|
||||
@import bourbon
|
||||
@import neat
|
||||
@import ~bourbon/app/assets/stylesheets/bourbon
|
||||
@import ~bourbon-neat/app/assets/stylesheets/neat
|
||||
@import wyrm_core/mixin
|
||||
@import wyrm_core/grid_settings
|
||||
@import _theme_badge_fa
|
@ -13,11 +13,11 @@
|
||||
@import theme_variables
|
||||
|
||||
// bourbon.io framework
|
||||
@import bourbon
|
||||
@import ~bourbon/app/assets/stylesheets/bourbon
|
||||
|
||||
// Bourbon.io/neat framework, with some default media queries
|
||||
@import wyrm_core/grid_settings
|
||||
@import neat
|
||||
@import ~bourbon-neat/app/assets/stylesheets/neat
|
||||
// Some corrections for neat
|
||||
@import wyrm_core/neat_extra
|
||||
|
54
webpack.common.js
Normal file
54
webpack.common.js
Normal file
@ -0,0 +1,54 @@
|
||||
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]',
|
||||
outputPath: 'fonts/',
|
||||
publicPath: '/_static/fonts',
|
||||
}
|
||||
}]
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
// Options similar to the same options in webpackOptions.output
|
||||
// both options are optional
|
||||
filename: 'css/theme.css'
|
||||
})
|
||||
]
|
||||
};
|
20
webpack.dev.js
Normal file
20
webpack.dev.js
Normal file
@ -0,0 +1,20 @@
|
||||
const path = require('path');
|
||||
const merge = require('webpack-merge');
|
||||
const common = require('./webpack.common.js');
|
||||
const exec = require('child_process').exec;
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: 'development',
|
||||
watch: true,
|
||||
devServer: {
|
||||
contentBase: path.join(__dirname, 'docs/_build/html'),
|
||||
compress: false,
|
||||
port: 7070,
|
||||
after: function (app, server) {
|
||||
exec('rm -rf docs/_build && sphinx-build docs docs/_build/html', (err, stdout, stderr) => {
|
||||
if (stdout) process.stdout.write(stdout);
|
||||
if (stderr) process.stderr.write(stderr);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
6
webpack.prod.js
Normal file
6
webpack.prod.js
Normal file
@ -0,0 +1,6 @@
|
||||
const merge = require('webpack-merge');
|
||||
const common = require('./webpack.common.js');
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: 'production'
|
||||
});
|
Loading…
Reference in New Issue
Block a user