8
0

webpack.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. new UglifyJsWebpackPlugin( {
  26. sourceMap: true,
  27. uglifyOptions: {
  28. output: {
  29. // Preserve license comments starting with at least 30 `-` chars.
  30. comments: /^-{30,}/
  31. }
  32. }
  33. } )
  34. ]
  35. },
  36. plugins: [
  37. new CKEditorWebpackPlugin( {
  38. language: buildConfig.config.language,
  39. additionalLanguages: 'all'
  40. } ),
  41. new webpack.BannerPlugin( {
  42. banner: bundler.getLicenseBanner(),
  43. raw: true
  44. } )
  45. ],
  46. module: {
  47. rules: [
  48. {
  49. test: /\.svg$/,
  50. use: [ 'raw-loader' ]
  51. },
  52. {
  53. test: /\.css$/,
  54. use: [
  55. {
  56. loader: 'style-loader',
  57. options: {
  58. singleton: true
  59. }
  60. },
  61. {
  62. loader: 'postcss-loader',
  63. options: styles.getPostCssConfig( {
  64. themeImporter: {
  65. themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
  66. },
  67. minify: true
  68. } )
  69. },
  70. ]
  71. }
  72. ]
  73. }
  74. };