Load codemirror and codemirror-spell-checker without script-loader

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-06-03 22:54:03 +02:00
parent 23fa44cd36
commit e17cc6440f
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 118 additions and 76 deletions

View file

@ -1,9 +1,10 @@
/* eslint-env browser, jquery */
/* eslint no-console: ["error", { allow: ["warn", "error", "debug"] }] */
/* global CodeMirror, Cookies, moment, Idle, serverurl,
/* global Cookies, moment, Idle, serverurl,
key, Dropbox, ot, hex2rgb, Visibility */
import TurndownService from 'turndown'
import CodeMirror from 'codemirror/lib/codemirror.js'
import { saveAs } from 'file-saver'
import randomColor from 'randomcolor'

View file

@ -1,3 +1,39 @@
import 'codemirror/keymap/sublime'
import 'codemirror/keymap/emacs'
import 'codemirror/keymap/vim'
import 'codemirror/mode/gfm/gfm'
import 'codemirror/addon/mode/overlay.js'
import 'codemirror/addon/mode/simple.js'
import 'codemirror/addon/mode/multiplex.js'
import 'codemirror/addon/selection/active-line.js'
import 'codemirror/addon/search/searchcursor.js'
import 'codemirror/addon/search/search.js'
import 'codemirror/addon/search/jump-to-line.js'
import 'codemirror/addon/search/matchesonscrollbar.js'
import 'codemirror/addon/search/match-highlighter.js'
import 'codemirror/addon/scroll/simplescrollbars.js'
import 'codemirror/addon/scroll/annotatescrollbar.js'
import 'codemirror/addon/display/panel.js'
import 'codemirror/addon/display/placeholder.js'
import 'codemirror/addon/display/fullscreen.js'
import 'codemirror/addon/display/autorefresh.js'
import 'codemirror/addon/dialog/dialog.js'
import 'codemirror/addon/edit/matchbrackets.js'
import 'codemirror/addon/edit/closebrackets.js'
import 'codemirror/addon/edit/matchtags.js'
import 'codemirror/addon/edit/closetag.js'
import 'codemirror/addon/edit/continuelist.js'
import 'codemirror/addon/comment/comment.js'
import 'codemirror/addon/comment/continuecomment.js'
import 'codemirror/addon/wrap/hardwrap.js'
import 'codemirror/addon/fold/foldcode.js'
import 'codemirror/addon/fold/brace-fold.js'
import 'codemirror/addon/fold/foldgutter.js'
import 'codemirror/addon/fold/markdown-fold.js'
import 'codemirror/addon/fold/xml-fold.js'
import 'codemirror/addon/merge/merge.js'
import '../../../vendor/codemirror-spell-checker/spell-checker.min.js'
import * as utils from './utils'
import config from './config'
import statusBarTemplate from './statusbar.html'

View file

@ -20,7 +20,8 @@ module.exports = {
jQuery: 'jquery',
'window.jQuery': 'jquery',
'moment': 'moment',
'Handlebars': 'handlebars'
'Handlebars': 'handlebars',
CodeMirror: 'codemirror/lib/codemirror.js'
}),
new HtmlWebpackPlugin({
template: 'public/views/includes/header.ejs',
@ -215,10 +216,8 @@ module.exports = {
'script-loader!jquery-ui-resizable',
'script-loader!Idle.Js',
'expose-loader?exposes=LZString!lz-string',
'script-loader!codemirror',
'script-loader!inlineAttachment',
'script-loader!jqueryTextcomplete',
'script-loader!codemirrorSpellChecker',
'script-loader!codemirrorInlineAttachment',
'script-loader!ot',
'flowchart.js',
@ -265,10 +264,8 @@ module.exports = {
'script-loader!Idle.Js',
'script-loader!gist-embed',
'expose-loader?exposes=LZString!lz-string',
'script-loader!codemirror',
'script-loader!inlineAttachment',
'script-loader!jqueryTextcomplete',
'script-loader!codemirrorSpellChecker',
'script-loader!codemirrorInlineAttachment',
'script-loader!ot',
'flowchart.js',
@ -364,10 +361,8 @@ module.exports = {
modules: ['node_modules'],
extensions: ['.js'],
alias: {
codemirror: path.join(__dirname, 'node_modules/codemirror/codemirror.min.js'),
inlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'),
jqueryTextcomplete: path.join(__dirname, 'public/vendor/jquery-textcomplete/jquery.textcomplete.js'),
codemirrorSpellChecker: path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js'),
codemirrorInlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/codemirror.inline-attachment.js'),
ot: path.join(__dirname, 'public/vendor/ot/ot.min.js'),
mermaid: path.join(__dirname, 'node_modules/mermaid/dist/mermaid.min.js'),
@ -392,78 +387,88 @@ module.exports = {
},
module: {
rules: [{
test: /\.js$/,
use: [{ loader: 'babel-loader' }],
exclude: [/node_modules/, /public\/vendor/]
}, {
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
rules: [
{
test: require.resolve(path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js')),
use: {
loader: 'imports-loader',
options: {
publicPath: '',
imports: ['default codemirror CodeMirror']
}
},
'css-loader'
]
}, {
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'less-loader'
]
}, {
test: require.resolve('js-sequence-diagrams'),
use: [{
loader: 'imports-loader',
options: {
imports: ['default lodash _', 'default raphael Raphael', 'default eve eve']
}
},
{
test: /\.js$/,
use: [{ loader: 'babel-loader' }],
exclude: [/node_modules/, /public\/vendor/]
}, {
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '',
}
},
'css-loader'
]
}, {
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'less-loader'
]
}, {
test: require.resolve('js-sequence-diagrams'),
use: [{
loader: 'imports-loader',
options: {
imports: ['default lodash _', 'default raphael Raphael', 'default eve eve']
}
}]
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
use: [{ loader: 'file-loader' }]
}, {
test: /\.html$/,
use: [{ loader: 'string-loader' }]
}, {
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { prefix: 'font/', limit: '5000' }
}]
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '5000', mimetype: 'application/octet-stream' }
}]
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '10000', mimetype: 'svg+xml' }
}]
}, {
test: /\.png(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '10000', mimetype: 'image/png' }
}]
}, {
test: /\.gif(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '10000', mimetype: 'image/gif' }
}]
}]
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
use: [{ loader: 'file-loader' }]
}, {
test: /\.html$/,
use: [{ loader: 'string-loader' }]
}, {
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { prefix: 'font/', limit: '5000' }
}]
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '5000', mimetype: 'application/octet-stream' }
}]
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '10000', mimetype: 'svg+xml' }
}]
}, {
test: /\.png(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '10000', mimetype: 'image/png' }
}]
}, {
test: /\.gif(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'url-loader',
options: { limit: '10000', mimetype: 'image/gif' }
}]
}]
},
node: {
fs: 'empty'