Я пытаюсь использовать CodeMirror в ванильном TypeScript приложении JavaScript (без React или Angular , но с Bootstrap4 в качестве фреймворка CSS) с использованием модуля WebPack .
Код приложения
import * as CodeMirror from 'codemirror';
import 'codemirror/mode/xml/xml.js';
import 'codemirror/theme/blackboard.css';
const definition: HTMLTextAreaElement = document.getElementById('Definition')
as HTMLTextAreaElement;
const config: CodeMirror.EditorConfiguration = {
tabSize: 3,
lineNumbers: true,
mode: 'xml',
theme: 'blackboard'
};
const editor = CodeMirror.fromTextArea(definition, config);
package.json
{
"dependencies": {
"@types/codemirror": "0.0.72",
"@types/jquery": "^3.3.22",
"bootstrap": "^4.1.3",
"codemirror": "^5.45.0",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"popper": "^1.0.1",
"popper.js": "^1.14.6"
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"autoprefixer": "^9.3.1",
"babel-loader": "^8.0.4",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.6.0",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"extract-text-webpack-plugin": "^3.0.2",
"fetch": "^1.1.0",
"file-loader": "^2.0.0",
"font-awesome-loader": "^1.0.2",
"html-webpack-plugin": "^3.2.0",
"json-loader": "^0.5.7",
"mini-css-extract-plugin": "^0.4.5",
"node-sass": "^4.10.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"postcss-loader": "^3.0.0",
"precss": "^3.1.2",
"raw-loader": "^0.5.1",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"ts-loader": "^5.3.1",
"typescript": "^3.2.1",
"uglifyjs-webpack-plugin": "^2.0.1",
"url-loader": "^1.1.2",
"webpack": "^4.27.0",
"webpack-cli": "^3.1.2",
"webpack-node-externals": "^1.7.2"
}
}
webpack.config (раздел правил)
rules: [
// JavaScript
{
test: /\.jsx?$/, // JavaScript and Reactive JavaScript
exclude: /node_modules/,
use: {
loader: 'babel-loader', // Transpiles ES6 JavaScript files
options: {
presets: ['@babel/preset-env']
}
}
},
// TypeScript
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
},
// CSS
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader']
}
]
Приложение компилируется и собираетсябез ошибок и нет ошибок записи консоли, но макет CodeMirror не работает:
Любой совет / направление о том, где я иду не так, будетвысоко ценится.