webpack.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. 'use strict';
  6. /* eslint-env node */
  7. const path = require( 'path' );
  8. const webpack = require( 'webpack' );
  9. const { bundler, styles } = require( '@ckeditor/ckeditor5-dev-utils' );
  10. const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
  11. const UglifyJsWebpackPlugin = require( 'uglifyjs-webpack-plugin' );
  12. module.exports = {
  13. devtool: 'source-map',
  14. performance: { hints: false },
  15. entry: path.resolve( __dirname, 'src', 'ckeditor.js' ),
  16. output: {
  17. // The name under which the editor will be exported.
  18. library: 'BalloonEditor',
  19. path: path.resolve( __dirname, 'build' ),
  20. filename: 'ckeditor.js',
  21. libraryTarget: 'umd',
  22. libraryExport: 'default'
  23. },
  24. optimization: {
  25. minimizer: [
  26. new UglifyJsWebpackPlugin( {
  27. sourceMap: true,
  28. uglifyOptions: {
  29. output: {
  30. // Preserve CKEditor 5 license comments.
  31. comments: /^!/
  32. }
  33. }
  34. } )
  35. ]
  36. },
  37. plugins: [
  38. new CKEditorWebpackPlugin( {
  39. // UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
  40. // When changing the built-in language, remember to also change it in the editor's configuration (src/ckeditor.js).
  41. language: 'en',
  42. additionalLanguages: 'all'
  43. } ),
  44. new webpack.BannerPlugin( {
  45. banner: bundler.getLicenseBanner(),
  46. raw: true
  47. } )
  48. ],
  49. module: {
  50. rules: [
  51. {
  52. test: /\.svg$/,
  53. use: [ 'raw-loader' ]
  54. },
  55. {
  56. test: /\.css$/,
  57. use: [
  58. {
  59. loader: 'style-loader',
  60. options: {
  61. injectType: 'singletonStyleTag'
  62. }
  63. },
  64. {
  65. loader: 'postcss-loader',
  66. options: styles.getPostCssConfig( {
  67. themeImporter: {
  68. themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
  69. },
  70. minify: true
  71. } )
  72. },
  73. ]
  74. }
  75. ]
  76. }
  77. };