chore(build): drop webpack and use Hugo Pipes (#130)

This commit is contained in:
panda-z 2020-04-13 21:18:35 +08:00 committed by GitHub
parent d39d3e4439
commit 5657112dfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 8 additions and 5830 deletions

View file

@ -1,5 +0,0 @@
{
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-transform-runtime"],
"ignore": []
}

View file

@ -64,22 +64,9 @@ defaultContentLanguage = "en" # en / zh-cn / other...
主题提供了 `center`,` right`, `left`,` music`, `admonition` 这些 shortcodes并支持为内置的 `figure` 设置 `center`,` right`, `left` 这三种 class 值。点击[这里](https://blog.olowolo.com/example-site/post/shortcodes/)查看详细内容。
## Theme Color
## Theme Color
主题内置了五种颜色 ( Default | Mint Green | Cobalt Blue | Hot Pink | Dark Violet ),你可以通过改变 [`/src/css/_variable.scss`](https://github.com/olOwOlo/hugo-theme-even/blob/master/src/css/_variables.scss#L5-L8) 文件中 `$theme-color-config` 的值来改变主题的颜色。
## Build
如果你更改了 `/src/` 目录下的任意文件,你需要重新编译它们。
```bash
cd ./themes/even/
# install dependencies
yarn install
# build
yarn build
```
_你需要先安装 **[Yarn](https://yarnpkg.com/)** 和 **[Node.js](https://nodejs.org/)**。_
## Update Theme

View file

@ -64,22 +64,9 @@ You can customize something for a single content in the content's front-matter.
This theme provides `center`,` right`, `left`,` music`, `admonition` shortcodes, and support `center`,` right`, `left` class for the built-in `figure`. See more information from [there](https://blog.olowolo.com/example-site/post/shortcodes/).
## Theme Color
## Theme Color
There are five built-in theme colors ( Default | Mint Green | Cobalt Blue | Hot Pink | Dark Violet ), you can config it by changing the `$theme-color-config` value in [`/src/css/_variable.scss`](https://github.com/olOwOlo/hugo-theme-even/blob/master/src/css/_variables.scss#L5-L8).
## Build
If you changed any file under `/src/`, you need to rebuild.
```bash
cd ./themes/even/
# install dependencies
yarn install
# build
yarn build
```
_You need to install **[Yarn](https://yarnpkg.com/)** and **[Node.js](https://nodejs.org/)** first._
## Update Theme

View file

@ -277,4 +277,3 @@ Even.responsiveTable = function() {
}
};
export {Even}

View file

@ -1,7 +1,3 @@
import {Even} from './even.js'
import '../css/style.scss'
$(document).ready(function () {
Even.backToTop();
Even.mobileNavbar();

View file

@ -61,7 +61,8 @@
{{- end -}}
<!-- Styles -->
<link href="{{ print "dist/" .Site.Data.even.assets.even.css | relURL }}" rel="stylesheet">
{{ $style := resources.Get "sass/main.scss" | toCSS | minify | fingerprint }}
<link href="{{ $style.Permalink }}" rel="stylesheet">
{{ if .Site.Params.publicCDN.enable -}}
{{ if .Site.Params.fancybox }}{{ .Site.Params.publicCDN.fancyboxCSS | safeHTML }}{{ end }}
{{- else -}}

View file

@ -67,7 +67,10 @@
<link rel="stylesheet" href="{{ "lib/js-sequence-diagrams/sequence-diagram-2.0.1.min.css" | relURL }}" integrity="sha384-6QbLKJMz5dS3adWSeINZe74uSydBGFbnzaAYmp+tKyq60S7H2p6V7g1TysM5lAaF" crossorigin="anonymous">
{{- end -}}
{{- end }}
<script type="text/javascript" src="{{ print "dist/" .Site.Data.even.assets.even.js | relURL }}"></script>
{{ $even := resources.Get "js/even.js" }}
{{ $main := resources.Get "js/main.js" }}
{{ $js := slice $even $main | resources.Concat "js/main.js" | fingerprint }}
<script type="text/javascript" src="{{ $js.Permalink }}"></script>
{{- if and (or .Params.mathjax (and .Site.Params.mathjax (ne .Params.mathjax false))) (or .IsPage .IsHome) }}
<script type="text/javascript">

View file

@ -1,32 +0,0 @@
{
"name": "even-src",
"version": "1.0.0",
"description": "even source file",
"main": "index.js",
"scripts": {
"start": "hugo server --source=exampleSite --themesDir=../.. --disableFastRender",
"build": "webpack",
"watch": "webpack --watch --progress --colors"
},
"author": "ahonn, olOwOlo",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"assets-webpack-plugin": "^3.9.7",
"autoprefixer": "^9.3.1",
"babel-loader": "^8.0.4",
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^1.0.1",
"file-loader": "^2.0.0",
"mini-css-extract-plugin": "^0.4.4",
"node-sass": "^4.10.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"uglifyjs-webpack-plugin": "^2.0.1",
"webpack": "^4.25.0",
"webpack-cli": "^3.1.2"
}
}

View file

@ -1,7 +0,0 @@
module.exports = {
plugins: [
require('autoprefixer')({
browsers: ['> 1%', 'last 2 versions', 'ie >= 9']
})
]
};

View file

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -1,87 +0,0 @@
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const AssetsWebpackPlugin = require('assets-webpack-plugin');
const extractSass = new MiniCssExtractPlugin({
filename: `even.[contenthash:8].min.css`
});
const cleanBuild = new CleanWebpackPlugin([
'static/dist/*'
]);
const assetsManifest = new AssetsWebpackPlugin({
filename: 'assets.json',
path: path.join(__dirname, 'data/even'),
fullPath: false,
processOutput: assets => {
const output = {};
Object.keys(assets)
.filter(bundle => bundle !== '')
.forEach(bundle => output[bundle] = assets[bundle]);
return JSON.stringify(output, null, 2);
}
});
module.exports = {
mode: 'production',
devtool: 'source-map',
entry: {
even: path.join(__dirname, 'src/js/main.js')
},
output: {
path: path.join(__dirname, 'static/dist'),
filename: `[name].[contenthash:8].min.js`,
chunkFilename: '[name].[contenthash:8].min.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader', options: { minimize: true, sourceMap: true }
}, {
loader: 'postcss-loader', options: { sourceMap: true }
}, {
loader: 'sass-loader', options: { sourceMap: true }
}
]
},
{
test: /iconfont\.(woff|woff2|eot|ttf|otf|svg)$/,
use: ['file-loader?name=[path][name].[ext]?hash=[hash:7]']
},
{
test: /apple-chancery-webfont\.(woff|woff2|eot|ttf|otf|svg)$/,
use: ['file-loader?name=[path][name].[ext]']
}
]
},
plugins: [extractSass, assetsManifest, cleanBuild],
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: {
map: {
inline: false,
annotation: true,
}
}
})
]
}
};

5664
yarn.lock

File diff suppressed because it is too large Load diff