webpack.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. const buildConfig = require( './build-config' );
  13. module.exports = {
  14. devtool: 'source-map',
  15. performance: { hints: false },
  16. entry: path.resolve( __dirname, 'src', 'ckeditor.js' ),
  17. output: {
  18. path: path.resolve( __dirname, 'build' ),
  19. filename: 'ckeditor.js',
  20. libraryTarget: 'umd',
  21. libraryExport: 'default',
  22. library: buildConfig.moduleName
  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. language: buildConfig.config.language,
  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. singleton: true
  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. };