1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Make red.min.js a reusable library

This commit is contained in:
Nick O'Leary 2016-11-02 22:53:18 +00:00
parent 3489fe0cf4
commit 1c3a97a71a
5 changed files with 66 additions and 49 deletions

View File

@ -98,7 +98,7 @@ module.exports = function(grunt) {
src: [ src: [
// Ensure editor source files are concatenated in // Ensure editor source files are concatenated in
// the right order // the right order
"editor/js/main.js", "editor/js/red.js",
"editor/js/events.js", "editor/js/events.js",
"editor/js/i18n.js", "editor/js/i18n.js",
"editor/js/settings.js", "editor/js/settings.js",
@ -150,11 +150,6 @@ module.exports = function(grunt) {
"public/vendor/vendor.css": [ "public/vendor/vendor.css": [
// TODO: resolve relative resource paths in // TODO: resolve relative resource paths in
// bootstrap/FA/jquery // bootstrap/FA/jquery
],
"public/vendor/vendor-jquery.js": [
"editor/vendor/jquery/js/jquery-1.11.3.min.js",
"editor/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js",
"editor/vendor/jquery/js/jquery.ui.touch-punch.min.js",
] ]
} }
} }
@ -162,7 +157,8 @@ module.exports = function(grunt) {
uglify: { uglify: {
build: { build: {
files: { files: {
'public/red/red.min.js': 'public/red/red.js' 'public/red/red.min.js': 'public/red/red.js',
'public/red/main.min.js': 'public/red/main.js'
} }
} }
}, },
@ -193,7 +189,8 @@ module.exports = function(grunt) {
attachCopyright: { attachCopyright: {
js: { js: {
src: [ src: [
'public/red/red.min.js' 'public/red/red.min.js',
'public/red/main.min.js'
] ]
}, },
css: { css: {
@ -272,40 +269,45 @@ module.exports = function(grunt) {
copy: { copy: {
build: { build: {
files:[{ files:[
cwd: 'editor/images', {
src: '**', src: 'editor/js/main.js',
expand: true, dest: 'public/red/main.js'
dest: 'public/red/images/' },
}, {
{ cwd: 'editor/images',
cwd: 'editor/vendor', src: '**',
src: [ expand: true,
'ace/**', dest: 'public/red/images/'
//'bootstrap/css/**', },
'bootstrap/img/**', {
'jquery/css/**', cwd: 'editor/vendor',
'font-awesome/**' src: [
], 'ace/**',
expand: true, //'bootstrap/css/**',
dest: 'public/vendor/' 'bootstrap/img/**',
}, 'jquery/css/**',
{ 'font-awesome/**'
cwd: 'editor/icons', ],
src: '**', expand: true,
expand: true, dest: 'public/vendor/'
dest: 'public/icons/' },
}, {
{ cwd: 'editor/icons',
expand: true, src: '**',
src: ['editor/index.html','editor/favicon.ico'], expand: true,
dest: 'public/', dest: 'public/icons/'
flatten: true },
}, {
{ expand: true,
src: 'CHANGELOG.md', src: ['editor/index.html','editor/favicon.ico'],
dest: 'public/red/about' dest: 'public/',
} flatten: true
},
{
src: 'CHANGELOG.md',
dest: 'public/red/about'
}
] ]
}, },
release: { release: {
@ -431,7 +433,7 @@ module.exports = function(grunt) {
grunt.registerTask('build', grunt.registerTask('build',
'Builds editor content', 'Builds editor content',
['clean:build','concat:build','concat:vendor','uglify:build','sass:build','jsonlint:messages','copy:build','attachCopyright']); ['clean:build','concat:build','concat:vendor','copy:build','uglify:build','sass:build','jsonlint:messages','attachCopyright']);
grunt.registerTask('dev', grunt.registerTask('dev',
'Developer mode: run node-red, watch for source changes and build/restart', 'Developer mode: run node-red, watch for source changes and build/restart',

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
**/ **/
var RED = (function() { (function() {
function loadNodeList() { function loadNodeList() {
@ -261,8 +261,4 @@ var RED = (function() {
RED.settings.init(loadEditor); RED.settings.init(loadEditor);
}) })
}); });
return {
};
})(); })();

16
editor/js/red.js Normal file
View File

@ -0,0 +1,16 @@
/**
* Copyright 2013, 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var RED = {};

View File

@ -163,6 +163,7 @@
<script src="vendor/ace/ace.js"></script> <script src="vendor/ace/ace.js"></script>
<script src="vendor/ace/ext-language_tools.js"></script> <script src="vendor/ace/ext-language_tools.js"></script>
<script src="{{ asset.red }}"></script> <script src="{{ asset.red }}"></script>
<script src="{{ asset.main }}"></script>
</body> </body>
</html> </html>

View File

@ -31,7 +31,9 @@ var defaultContext = {
image: "red/images/node-red.png" image: "red/images/node-red.png"
}, },
asset: { asset: {
red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js" red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js",
main: (process.env.NODE_ENV == "development")? "red/main.js":"red/main.min.js",
} }
}; };