webpack.config.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @license Copyright (c) 2014-2020, 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 TerserWebpackPlugin = require( 'terser-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: 'ClassicEditor',
  19. path: path.resolve( __dirname, 'build' ),
  20. filename: 'ckeditor.js',
  21. libraryTarget: 'umd',
  22. libraryExport: 'default'
  23. },
  24. optimization: {
  25. minimizer: [
  26. new TerserWebpackPlugin( {
  27. sourceMap: true,
  28. terserOptions: {
  29. output: {
  30. // Preserve CKEditor 5 license comments.
  31. comments: /^!/
  32. }
  33. },
  34. extractComments: false
  35. } )
  36. ]
  37. },
  38. plugins: [
  39. new CKEditorWebpackPlugin( {
  40. // UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
  41. // When changing the built-in language, remember to also change it in the editor's configuration (src/ckeditor.js).
  42. language: 'zh-cn',
  43. additionalLanguages: 'all'
  44. } ),
  45. new webpack.BannerPlugin( {
  46. banner: bundler.getLicenseBanner(),
  47. raw: true
  48. } )
  49. ],
  50. module: {
  51. rules: [
  52. {
  53. test: /\.svg$/,
  54. use: [ 'raw-loader' ]
  55. },
  56. {
  57. test: /\.css$/,
  58. use: [
  59. {
  60. loader: 'style-loader',
  61. options: {
  62. injectType: 'singletonStyleTag',
  63. attributes: {
  64. 'data-cke': true
  65. }
  66. }
  67. },
  68. {
  69. loader: 'postcss-loader',
  70. options: styles.getPostCssConfig( {
  71. themeImporter: {
  72. themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
  73. },
  74. minify: true
  75. } )
  76. },
  77. ]
  78. }
  79. ]
  80. }
  81. };