Run webpack js through Prettier JS formatter

Uses Prettier with no options. I'm fine accepting this as the default
style for our Javascript and autoformatting src/js/*.js as well. I left
those changes out for now.
This commit is contained in:
Anthony Johnson 2019-07-26 15:35:35 -06:00
parent 78287f0634
commit 2d874544b2
3 changed files with 56 additions and 55 deletions

View File

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

View File

@ -1,34 +1,31 @@
const path = require('path'); const path = require("path");
const merge = require('webpack-merge'); const merge = require("webpack-merge");
const exec = require('child_process').exec; const exec = require("child_process").exec;
const WatchPlugin = require('webpack-watch-files-plugin').default; const WatchPlugin = require("webpack-watch-files-plugin").default;
const ShellPlugin = require('webpack-shell-plugin'); const ShellPlugin = require("webpack-shell-plugin");
const common = require('./webpack.common.js'); const common = require("./webpack.common.js");
module.exports = merge(common, { module.exports = merge(common, {
mode: 'development', mode: "development",
watch: true, watch: true,
devServer: { devServer: {
contentBase: path.join(__dirname, 'docs/build/html'), contentBase: path.join(__dirname, "docs/build/html"),
watchContentBase: true, watchContentBase: true,
compress: false, compress: false,
port: 1919, port: 1919,
hot: false, hot: false,
liveReload: true, liveReload: true,
publicPath: '/_static/' publicPath: "/_static/"
}, },
plugins: [ plugins: [
new WatchPlugin({ new WatchPlugin({
files: [ files: ["./docs/**/*.rst", "./docs/**/*.py"]
'./docs/**/*.rst',
'./docs/**/*.py',
]
}), }),
new ShellPlugin({ new ShellPlugin({
onBuildEnd: ['make -C docs clean html'], onBuildEnd: ["make -C docs clean html"],
// dev=false here to force every build to trigger make, the default is // dev=false here to force every build to trigger make, the default is
// first build only. // first build only.
dev: false, dev: false
}), })
] ]
}); });

View File

@ -1,11 +1,11 @@
const merge = require('webpack-merge'); const merge = require("webpack-merge");
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const TerserPlugin = require('terser-webpack-plugin'); const TerserPlugin = require("terser-webpack-plugin");
const common = require('./webpack.common.js'); const common = require("./webpack.common.js");
module.exports = merge(common, { module.exports = merge(common, {
mode: 'production', mode: "production",
optimization: { optimization: {
minimizer: [new TerserPlugin(), new OptimizeCssAssetsPlugin({})], minimizer: [new TerserPlugin(), new OptimizeCssAssetsPlugin({})]
}, }
}); });