Permalink
Browse files

General bugfixes and updates

  • Loading branch information...
1 parent 63b267c commit 37de917572001de9d9d6e20445bdcae1c0b2ad92 @artf committed Jan 26, 2016
View
@@ -6,7 +6,6 @@ grapes.sublime-project
grapes.sublime-workspace
private/
-libs/
vendor/
node_modules/
bower_components/
View
@@ -2,35 +2,59 @@ module.exports = function(grunt) {
var appPath = 'src',
buildPath = 'dist',
- configPath = 'config/require-config.js';
+ stylePath = 'styles',
+ configPath = 'config/require-config.js',
+ port = grunt.option('port') || 8000;
- grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-contrib-sass');
- grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-connect');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-cssmin');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-sass');
+ grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-bowercopy');
grunt.loadNpmTasks('grunt-mocha');
grunt.initConfig({
appDir: appPath,
builtDir: buildPath,
+ styleDir: stylePath,
pkg: grunt.file.readJSON("package.json"),
+
requirejs:{
compile:{
options: {
- mainConfigFile: '<%= appDir %>/' + configPath,
- appDir: '<%= appDir %>',
- dir: '<%= builtDir %>',
- baseUrl: './',
- name: 'main',
- removeCombined: true,
- findNestedDependencies: true,
- keepBuildDir: true,
- inlineText: true,
- optimize: 'none'
- //paths: { "jquery": "empty:" }, //try to exclude
+ mainConfigFile: '<%= appDir %>/' + configPath,
+ appDir: '<%= appDir %>',
+ dir: '<%= builtDir %>',
+ baseUrl: './',
+ name: 'main',
+ include: ["./../vendor/almond/almond"],
+ removeCombined: true,
+ findNestedDependencies: true,
+ keepBuildDir: true,
+ inlineText: true,
+ optimize: 'none',
+ wrap: {
+ start: "(function (root, factory) {"+
+ "if (typeof define === 'function' && define.amd)"+
+ "define([], factory);"+
+ "else if(typeof exports === 'object' && typeof module === 'object')"+
+ "module.exports = mod();"+
+ "else "+
+ "root.<%= pkg.name %> = root.GrapesJS = factory();"+
+ "}(this, function () {",
+ end: "return require('editor/main'); }));"
+ },
+
+ paths: {
+ "jquery": "wrappers/jquery",
+ }
+
}
}
},
@@ -44,8 +68,8 @@ module.exports = function(grunt) {
uglify: {
options: {
- banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */'
- },
+ banner: '/*! <%= pkg.name %> - v<%= pkg.version %> */\n'
+ },
build:{
files: {
'<%= builtDir %>/grapes.min.js': ['<%= builtDir %>/main.js']
@@ -57,14 +81,37 @@ module.exports = function(grunt) {
dist: {
files: [{
expand: true,
- cwd: 'styles/scss',
+ cwd: '<%= styleDir %>/scss',
src: ['**/*.scss'],
- dest: 'styles/css',
+ dest: '<%= styleDir %>/css',
ext: '.css'
}]
}
},
+ cssmin: {
+ target: {
+ files: [{
+ expand: true,
+ flatten: true,
+ src: [
+ '<%= styleDir %>/css/main.css',
+ 'vendor/codemirror/lib/codemirror.css',
+ 'vendor/codemirror/theme/hopscotch.css'
+ ],
+ dest: '<%= builtDir %>',
+ ext: '.min.css'
+ }]
+ }
+ },
+
+ concat: {
+ css: {
+ src: ['<%= builtDir %>/*.min.css'],
+ dest: '<%= builtDir %>/grapes.min.css'
+ }
+ },
+
mocha: {
test: {
src: ['test/index.html'],
@@ -73,24 +120,12 @@ module.exports = function(grunt) {
},
connect: {
- /*
- dist: {
- options: {
- port: 8001,
- open: {
- target: 'http://localhost:8001',
- //appName: 'Firefox' // 'Google Chrome'
- }
- }
- },
- */
- test: {
- options: {
- open: {
- target: 'http://localhost:8000/test',
- }
- }
- }
+ server: {
+ options: {
+ port: port,
+ open: true
+ }
+ },
},
bowercopy: {
@@ -102,11 +137,8 @@ module.exports = function(grunt) {
destPrefix: 'vendor'
},
files: {
+ 'almond/almond.js' : 'almond/almond.js',
'jquery/jquery.js' : 'jquery/dist/jquery.min.js',
- 'jquery-ui/jquery-ui-core.js' : 'jquery.ui/ui/core.js',
- 'jquery-ui/jquery-ui-mouse.js' : 'jquery.ui/ui/mouse.js',
- 'jquery-ui/jquery-ui-widget.js' : 'jquery.ui/ui/widget.js',
- 'jquery-ui/jquery-ui.js' : 'jquery.ui/ui/resizable.js',
'underscore/underscore.js' : 'underscore/underscore-min.js',
'backbone/backbone.js' : 'backbone/backbone-min.js',
'backbone-undo/backbone-undo.js' : 'Backbone.Undo/Backbone.Undo.js',
@@ -116,6 +148,9 @@ module.exports = function(grunt) {
'spectrum/spectrum.js' : 'spectrum/spectrum.js',
'codemirror' : 'codemirror',
'codemirror-formatting' : 'codemirror-formatting/formatting.js',
+ 'mocha' : 'mocha',
+ 'chai' : 'chai/chai.js',
+ 'sinon' : 'sinonjs/sinon.js',
},
}
},
@@ -134,33 +169,41 @@ module.exports = function(grunt) {
tasks: ['mocha'],
options: { livereload: true }, //default port 35729
}
+ },
+
+ clean: {
+ all: ["<%= builtDir %>/*", "!<%= builtDir %>/grapes.min.js", "!<%= builtDir %>/grapes.min.css"]
+ },
+
+ copy: {
+ fonts: {
+ cwd: '<%= styleDir %>/fonts',
+ src: '**/*',
+ dest: '<%= builtDir %>/fonts',
+ expand: true
+ }
}
});
/**
- * Need to copy require configs cause r.js will try to load them from the path indicated inside
- * main.js file. This is the only way I have found to do it and only for the pleasure of using separate config
- * requirejs file.
+ * Have to copy require configs cause r.js will try to load them from the path indicated inside
+ * main.js file. This is the only way I have found to do it
* */
- grunt.registerTask('before-requirejs', function() {
- //if(grunt.file.exists(buildPath))
- //grunt.file.delete(buildPath);
+ grunt.registerTask('before-rjs', function() {
+ if(grunt.file.exists(buildPath))
+ grunt.file.delete(buildPath);
grunt.file.mkdir(buildPath);
grunt.file.copy(appPath + '/' + configPath, buildPath + '/' + appPath + '/' + configPath);
});
- grunt.registerTask('after-requirejs', function() {
- //grunt.file.copy(buildPath + '/main.js', buildPath + '/main.min.js');
- });
-
grunt.registerTask('bower', ['bowercopy']);
- grunt.registerTask('dev', ['connect', 'watch']);
+ grunt.registerTask('dev', ['bowercopy', 'connect', 'watch']);
- grunt.registerTask('test', ['mocha']);
+ grunt.registerTask('test', ['jshint', 'mocha']);
- grunt.registerTask('deploy', ['jshint', 'before-requirejs', 'requirejs', 'after-requirejs', 'uglify']);
+ grunt.registerTask('build', ['bowercopy', 'jshint', 'sass', 'before-rjs', 'requirejs', 'uglify', 'cssmin', 'concat', 'clean', 'copy']);
grunt.registerTask('default', ['dev']);
View
@@ -0,0 +1,25 @@
+Copyright (c) 2016, Artur Arseniev
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+- Neither the name "GrapesJS" nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Oops, something went wrong.

0 comments on commit 37de917

Please sign in to comment.