webpack.config.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // webpack.config.js
  2. 'use strict';
  3. /* eslint-env node */
  4. import path from 'path';
  5. import { CKEditorTranslationsPlugin } from '@ckeditor/ckeditor5-dev-translations';
  6. import { styles } from '@ckeditor/ckeditor5-dev-utils';
  7. import { fileURLToPath } from 'url';
  8. import { createRequire } from 'module';
  9. const __filename = fileURLToPath(import.meta.url);
  10. const __dirname = path.dirname(__filename);
  11. const require = createRequire(import.meta.url);
  12. export default {
  13. devtool: 'source-map',
  14. performance: { hints: false },
  15. entry: path.resolve(__dirname, 'src', 'ckeditor.js'),
  16. output: {
  17. library: {
  18. name: 'CustomEditors',
  19. type: 'umd',
  20. export: 'default'
  21. },
  22. path: path.resolve(__dirname, 'build'),
  23. filename: 'ckeditor.js',
  24. globalObject: 'this'
  25. },
  26. plugins: [
  27. // More plugins.
  28. // ...
  29. new CKEditorTranslationsPlugin({
  30. // See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
  31. language: 'ru',
  32. additionalLanguages: 'all',
  33. })
  34. ],
  35. module: {
  36. rules: [
  37. {
  38. test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
  39. use: ['raw-loader']
  40. },
  41. {
  42. test: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/,
  43. use: [
  44. {
  45. loader: 'style-loader',
  46. options: {
  47. injectType: 'singletonStyleTag',
  48. attributes: {
  49. 'data-cke': true
  50. }
  51. }
  52. },
  53. 'css-loader',
  54. {
  55. loader: 'postcss-loader',
  56. options: {
  57. postcssOptions: styles.getPostCssConfig({
  58. themeImporter: {
  59. themePath: require.resolve('@ckeditor/ckeditor5-theme-lark')
  60. },
  61. minify: true
  62. })
  63. }
  64. }
  65. ]
  66. }
  67. ]
  68. }
  69. };