forked from ckeditor/ckeditor4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NPM script for inlining ckeditor_base.js.
- Loading branch information
1 parent
7640ab8
commit 2d376c2
Showing
5 changed files
with
359 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
/** | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* jshint node: true, browser: false, es3: false, esversion: 6 */ | ||
|
||
'use strict'; | ||
const fs = require( 'fs' ); | ||
const uglify = require( 'uglify-js' ); | ||
const replace = require( 'replace-in-file' ); | ||
|
||
const code = fs.readFileSync( './core/ckeditor_base.js', 'utf8' ); | ||
const minified = uglify.minify( code, { | ||
ie8: true | ||
} ); | ||
|
||
try { | ||
const results = replace.sync( { | ||
encoding: 'utf8', | ||
files: './ckeditor.js', | ||
from: /\/\/\s+replace_start\n(.|\n|\t|\r)*?\n\/\/\s+replace_end/, | ||
to: `// replace_start\n${ minified.code }\n// replace_end` | ||
} ); | ||
|
||
console.log( `Replacement successful: ${ results }` ); | ||
} | ||
catch ( error ) { | ||
console.error( `Replacement failed: ${ error }` ); | ||
} |
Oops, something went wrong.