webpack.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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: 'CustomEditors',
  18. path: path.resolve(__dirname, 'build'),
  19. filename: 'ckeditor.js',
  20. libraryTarget: 'umd',
  21. libraryExport: 'default'
  22. },
  23. plugins: [
  24. // More plugins.
  25. // ...
  26. new CKEditorTranslationsPlugin({
  27. // See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
  28. language: 'ru',
  29. additionalLanguages: 'all',
  30. })
  31. ],
  32. module: {
  33. rules: [
  34. {
  35. test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
  36. use: ['raw-loader']
  37. },
  38. {
  39. test: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/,
  40. use: [
  41. {
  42. loader: 'style-loader',
  43. options: {
  44. injectType: 'singletonStyleTag',
  45. attributes: {
  46. 'data-cke': true
  47. }
  48. }
  49. },
  50. 'css-loader',
  51. {
  52. loader: 'postcss-loader',
  53. options: {
  54. postcssOptions: styles.getPostCssConfig({
  55. themeImporter: {
  56. themePath: require.resolve('@ckeditor/ckeditor5-theme-lark')
  57. },
  58. minify: true
  59. })
  60. }
  61. }
  62. ]
  63. }
  64. ]
  65. }
  66. };