webpack.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  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: 'InlineEditor',
  19. path: path.resolve( __dirname, 'build' ),
  20. filename: 'ckeditor.js',
  21. libraryTarget: 'umd',
  22. libraryExport: 'default'
  23. },
  24. optimization: {
  25. minimizer: [
  26. // Use the newest version of UglifyJsWebpackPlugin that fixes the `inline` optimization bug.
  27. // See https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/264.
  28. new UglifyJsWebpackPlugin( {
  29. sourceMap: true,
  30. uglifyOptions: {
  31. output: {
  32. // Preserve CKEditor 5 license comments.
  33. comments: /^!/
  34. }
  35. }
  36. } )
  37. ]
  38. },
  39. plugins: [
  40. new CKEditorWebpackPlugin( {
  41. // UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
  42. // When changing the built-in language, remember to also change it in the editor's configuration (src/ckeditor.js).
  43. language: 'en',
  44. additionalLanguages: 'all'
  45. } ),
  46. new webpack.BannerPlugin( {
  47. banner: bundler.getLicenseBanner(),
  48. raw: true
  49. } )
  50. ],
  51. module: {
  52. rules: [
  53. {
  54. test: /\.svg$/,
  55. use: [ 'raw-loader' ]
  56. },
  57. {
  58. test: /\.css$/,
  59. use: [
  60. {
  61. loader: 'style-loader',
  62. options: {
  63. singleton: true
  64. }
  65. },
  66. {
  67. loader: 'postcss-loader',
  68. options: styles.getPostCssConfig( {
  69. themeImporter: {
  70. themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
  71. },
  72. minify: true
  73. } )
  74. },
  75. ]
  76. }
  77. ]
  78. }
  79. };