8
0

webpack.config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. entry: path.resolve( __dirname, 'src', 'ckeditor.js' ),
  16. output: {
  17. path: path.resolve( __dirname, 'build' ),
  18. filename: 'ckeditor.js',
  19. libraryTarget: 'umd',
  20. libraryExport: 'default',
  21. library: buildConfig.moduleName
  22. },
  23. optimization: {
  24. minimizer: [
  25. // Use the newest version of UglifyJsWebpackPlugin plugin that fixes `inline` optimization bug.
  26. // See https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/264.
  27. new UglifyJsWebpackPlugin( {
  28. sourceMap: true,
  29. uglifyOptions: {
  30. output: {
  31. // Preserve license comments starting with the exclamation mark (!).
  32. comments: /^!/
  33. }
  34. }
  35. } )
  36. ]
  37. },
  38. plugins: [
  39. new CKEditorWebpackPlugin( {
  40. language: buildConfig.config.language,
  41. additionalLanguages: 'all'
  42. } ),
  43. new webpack.BannerPlugin( {
  44. banner: bundler.getLicenseBanner(),
  45. raw: true
  46. } )
  47. ],
  48. module: {
  49. rules: [
  50. {
  51. test: /\.svg$/,
  52. use: [ 'raw-loader' ]
  53. },
  54. {
  55. test: /\.css$/,
  56. use: [
  57. {
  58. loader: 'style-loader',
  59. options: {
  60. singleton: true
  61. }
  62. },
  63. {
  64. loader: 'postcss-loader',
  65. options: styles.getPostCssConfig( {
  66. themeImporter: {
  67. themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
  68. },
  69. minify: true
  70. } )
  71. },
  72. ]
  73. }
  74. ]
  75. }
  76. };