Use webpack 5
All checks were successful
continuous-integration/drone/push Build is passing

- Generate to editor/dist
This commit is contained in:
Peter Stuifzand 2021-08-15 23:18:16 +02:00
parent 9f2a550340
commit 5850c556c8
9 changed files with 1962 additions and 1703 deletions

View File

@ -5,5 +5,5 @@ EXPOSE 80
WORKDIR /app WORKDIR /app
ADD ./wiki /app ADD ./wiki /app
ADD ./templates /app/templates ADD ./templates /app/templates
ADD ./dist /app/dist ADD ./editor/dist /app/dist
ENTRYPOINT ["/app/wiki"] ENTRYPOINT ["/app/wiki"]

3497
editor/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,9 @@
{ {
"name": "editor",
"main": "src/index.js",
"sideEffects": [
"**"
],
"dependencies": { "dependencies": {
"@egjs/hammerjs": "^2.0.17", "@egjs/hammerjs": "^2.0.17",
"axios": "^0.19.2", "axios": "^0.19.2",
@ -29,6 +34,7 @@
"sass-loader": "^7.3.1", "sass-loader": "^7.3.1",
"style-loader": "^1.3.0", "style-loader": "^1.3.0",
"timsort": "^0.3.0", "timsort": "^0.3.0",
"util": "^0.12.4",
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vis-data": "^6.6.1", "vis-data": "^6.6.1",
"vis-network": "^7.10.2", "vis-network": "^7.10.2",
@ -36,22 +42,26 @@
"wiki-list-editor": "file:../list-editor" "wiki-list-editor": "file:../list-editor"
}, },
"devDependencies": { "devDependencies": {
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^4.0.0-alpha.0",
"esm": "^3.2.25", "esm": "^3.2.25",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^5.0.0",
"mini-css-extract-plugin": "^0.9.0", "mini-css-extract-plugin": "^2.2.0",
"mocha": "^7.2.0", "mocha": "^7.2.0",
"mocha-webpack": "^1.1.0", "mocha-webpack": "^1.1.0",
"process": "^0.11.10",
"progress-bar-webpack-plugin": "^2.1.0",
"scss-loader": "0.0.1", "scss-loader": "0.0.1",
"webpack": "^4.46.0", "webpack": "^5.50.0",
"webpack-cli": "^3.3.12", "webpack-bundle-analyzer": "^4.4.2",
"webpack-dev-server": "^3.11.2" "webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.11.2",
"webpack-validator": "^3.0.1"
}, },
"scripts": { "scripts": {
"test": "node_modules/.bin/mocha -r esm", "test": "node_modules/.bin/mocha -r esm",
"watch": "webpack --watch --hide-modules", "watch": "webpack --watch",
"start": "webpack-dev-server --open --hot", "start": "webpack-dev-server --open --hot",
"build": "webpack --progress --hide-modules --mode=production", "build": "webpack --progress --mode=production",
"docker": "webpack --color=false --hide-modules --mode=production" "docker": "webpack --no-color --mode=production"
} }
} }

View File

@ -13,7 +13,7 @@
@import url('https://rsms.me/inter/inter.css'); @import url('https://rsms.me/inter/inter.css');
html { html {
font-family: 'Inter', sans-serif; font-family: 'Inter', sans-serif;
} }
body { body {

View File

@ -1,11 +1,10 @@
'use strict' 'use strict'
const Plugin = require('markdown-it-regexp') import Plugin from "markdown-it-regexp";
const extend = require('extend') import extend from "extend";
const sanitize = require('sanitize-filename') import sanitize from "sanitize-filename";
module.exports = (options) => {
export default (options) => {
const defaults = { const defaults = {
baseURL: '/', baseURL: '/',
relativeBaseURL: './', relativeBaseURL: './',

View File

@ -2,62 +2,78 @@ const path = require('path');
const {CleanWebpackPlugin} = require('clean-webpack-plugin'); const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const webpack = require('webpack');
module.exports = { module.exports = env => {
mode: 'development', return {
entry: { // mode: 'production',
index: './src/index.js' // devtool: 'source-map',
}, // entry: {
output: { // index: './src/index.js'
filename: '[name].bundle.js', // },
path: path.resolve(__dirname, '../dist') // output: {
}, // filename: '[name].bundle.js',
// path: path.resolve(__dirname, '../dist')
// },
module: { module: {
rules: [ rules: [
{ {
test: /\.s?css$/, test: /\.s?css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'] use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}, },
{ {
test: /\.(woff|woff2|eot|ttf|otf)$/, test: /\.(woff|woff2|eot|ttf|otf)$/,
loader: "file-loader", type: 'asset/resource'
options: {
name: '[name].[ext]',
outputPath: 'font/'
} }
]
},
stats: {
orphanModules: true
},
resolve: {
fallback: {
util: require.resolve("util/")
} }
] },
},
plugins: [ plugins: [
new CleanWebpackPlugin(), // new ProgressBarPlugin(),
new MiniCssExtractPlugin({ // new CleanWebpackPlugin(),
filename: '[name].css' new MiniCssExtractPlugin({
}), filename: '[name].css'
], }),
new webpack.EnvironmentPlugin({
devServer: { DEBUG: false,
contentBase: './dist', NODE_DEBUG: false,
hot: true })
}, ],
//
optimization: { // devServer: {
splitChunks: { // contentBase: './dist',
cacheGroups: { // hot: true
commons: { // },
test: /[\\/]node_modules[\\/]/, //
name: 'vendors', optimization: {
chunks: 'all' usedExports: true,
}, splitChunks: {
styles: { cacheGroups: {
name: 'styles', commons: {
test: /\.css$/, test: /[\\/]node_modules[\\/]/,
chunks: 'all', name: 'vendors',
enforce: true, chunks: 'all'
}, },
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true,
},
}
} }
} }
} }
}; };

View File

@ -4,6 +4,7 @@
"description": "Simple editor of lists", "description": "Simple editor of lists",
"author": "Peter Stuifzand <peter@p83.nl>", "author": "Peter Stuifzand <peter@p83.nl>",
"main": "index.js", "main": "index.js",
"sideEffects": ["**"],
"scripts": { "scripts": {
"test": "jasmine --require=esm" "test": "jasmine --require=esm"
}, },

View File

@ -1225,7 +1225,7 @@ func main() {
}) })
http.Handle("/search/", sh) http.Handle("/search/", sh)
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("./dist")))) http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("./editor/dist"))))
http.Handle("/save/", &saveHandler{}) http.Handle("/save/", &saveHandler{})
http.Handle("/edit/", &editHandler{}) http.Handle("/edit/", &editHandler{})
http.Handle("/history/", &historyHandler{}) http.Handle("/history/", &historyHandler{})

View File

@ -6,8 +6,8 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="redirect_uri" href="{{ .RedirectURI }}" /> <link rel="redirect_uri" href="{{ .RedirectURI }}" />
<link rel="stylesheet" href="/public/vendors.css" /> <link rel="stylesheet" href="/public/main.css" />
<link rel="stylesheet" href="/public/index.css" /> <link rel="stylesheet" href="/public/styles.css" />
<!-- <link rel="stylesheet" href="https://unpkg.com/prismjs@1.20.0/themes/prism-tomorrow.css"> --> <!-- <link rel="stylesheet" href="https://unpkg.com/prismjs@1.20.0/themes/prism-tomorrow.css"> -->
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/> --> <!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/> -->
<title>{{ .Title }} - Wiki</title> <title>{{ .Title }} - Wiki</title>
@ -87,7 +87,7 @@
<li><a href="/edit/[[page]]">Create a page</a></li> <li><a href="/edit/[[page]]">Create a page</a></li>
</ul> </ul>
</div> </div>
<script async src="/public/vendors.bundle.js"></script> <script async src="/public/vendors.js"></script>
<script async src="/public/index.bundle.js"></script> <script async src="/public/main.js"></script>
</body> </body>
</html> </html>