diff --git a/Gruntfile.js b/Gruntfile.js index 9d070f2029d8304f2b62193c241854db8c90516f..76a2c20fd60741488e96667e45aec2fbed436a58 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,586 +7,87 @@ module.exports = function (grunt) { 'use strict'; - // Required plugins - // _____________________________________________ - - var specRunner = require('./dev/tests/js/framework/spec_runner')(grunt), - svgo = require('imagemin-svgo'); + var _ = require('underscore'), + path = require('path'); require('./dev/tools/grunt/tasks/mage-minify')(grunt); - - // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt, { - pattern: ['grunt-*', '!grunt-template-jasmine-requirejs'] - }); - - // Configuration - // _____________________________________________ - - // Define Paths - // --------------------------------------------- - - var path = { - pub: 'pub/static/', - tmpLess: 'var/view_preprocessed/less/', - tmpSource: 'var/view_preprocessed/source/', - tmp: 'var', - css: { - setup: 'setup/pub/magento/setup/css' - }, - less: { - setup: 'setup/module/Magento/Setup/styles' - }, - uglify: { - legacy: 'lib/web/legacy-build.min.js' - }, - doc: 'lib/web/css/docs', - spec: 'dev/tests/js/spec' - }; - - // Define Themes - // --------------------------------------------- - - var theme = { - blank: { - area: 'frontend', - name: 'Magento/blank', - locale: 'en_US', - files: [ - 'css/styles-m', - 'css/styles-l' - ] - }, - luma: { - area: 'frontend', - name: 'Magento/luma', - locale: 'en_US', - files: [ - 'css/styles-m', - 'css/styles-l' - ] - }, - backend: { - area: 'adminhtml', - name: 'Magento/backend', - locale: 'en_US', - files: [ - 'css/styles-old', - 'css/styles', - 'css/pages', - 'css/admin' + require('load-grunt-config')(grunt, { + configPath: path.join(process.cwd(), 'dev/tools/grunt/configs'), + init: true, + loadGruntTasks: { + pattern: [ + 'grunt-*', + '!grunt-template-jasmine-requirejs' ] } - }; - - // Define Combos for repetitive code - // --------------------------------------------- - - var combo = { - // Run php script for gathering less simlynks into pub directory - collector: function (themeName) { - var cmdPlus = (/^win/.test(process.platform) == true) ? ' & ' : ' && '; - var command = 'grunt --force clean:' + themeName + cmdPlus; - command = command + 'php -f dev/tools/Magento/Tools/Webdev/less.php --' - + ' --locale=' + theme[themeName].locale - + ' --area=' + theme[themeName].area - + ' --theme=' + theme[themeName].name - + ' --files=' + theme[themeName].files.join(','); - return command; - }, - autopath: function (themeName) { - return path.pub - + theme[themeName].area + '/' - + theme[themeName].name + '/' - + theme[themeName].locale + '/'; - }, - lessFiles: function (themeName) { - var lessStringArray = [], - cssStringArray = [], - lessFiles = {}, - i = 0; - for (i; i < theme[themeName].files.length; i++) { - cssStringArray[i] = path.pub - + theme[themeName].area + '/' - + theme[themeName].name + '/' - + theme[themeName].locale + '/' - + theme[themeName].files[i] + '.css'; - lessStringArray[i] = path.pub - + theme[themeName].area + '/' - + theme[themeName].name + '/' - + theme[themeName].locale + '/' - + theme[themeName].files[i] + '.less'; - - lessFiles[cssStringArray[i]] = lessStringArray[i]; - } - return lessFiles; - } - }; - - // Tasks - // _____________________________________________ - - grunt.initConfig({ - - // Project settings - path: path, - theme: theme, - combo: combo, - - // Execution into cmd - // --------------------------------------------- - - exec: { - blank: { - cmd: function () { - return combo.collector('blank'); - } - }, - luma: { - cmd: function () { - return combo.collector('luma'); - } - }, - backend: { - cmd: function () { - return combo.collector('backend'); - } - }, - all: { - cmd: function () { - var command = '', - cmdPlus = (/^win/.test(process.platform) == true) ? ' & ' : ' && ', - themes = Object.keys(theme), - i = 0; - for (i; i < themes.length; i++) { - command += combo.collector(themes[i]) + cmdPlus; - } - return 'echo ' + command; - } - } - }, - - // Cleanup temporary files - // --------------------------------------------- - - clean: { - var: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.tmp %>/cache/**/*', - '<%= path.tmp %>/generation/**/*', - '<%= path.tmp %>/log/**/*', - '<%= path.tmp %>/maps/**/*', - '<%= path.tmp %>/page_cache/**/*', - '<%= path.tmp %>/tmp/**/*', - '<%= path.tmp %>/view/**/*', - '<%= path.tmp %>/view_preprocessed/**/*' - ] - }] - }, - pub: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.pub %>frontend/**/*', - '<%= path.pub %>adminhtml/**/*' - ] - }] - }, - styles: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.tmp %>/view_preprocessed/**/*', - '<%= path.tmp %>/cache/**/*', - '<%= path.pub %>frontend/**/*.less', - '<%= path.pub %>frontend/**/*.css', - '<%= path.pub %>adminhtml/**/*.less', - '<%= path.pub %>adminhtml/**/*.css' - ] - }] - }, - // Layout & templates cleanup - markup: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.tmp %>/cache/**/*', - '<%= path.tmp %>/generation/**/*', - '<%= path.tmp %>/page_cache/**/*' - ] - }] - }, - js: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.pub %>**/*.js', - '<%= path.pub %>**/*.html', - '<%= path.pub %>_requirejs/**/*' - ] - }] - }, - blank: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.tmp %>/cache/**/*', - '<%= combo.autopath("blank", "pub") %>**/*', - '<%= combo.autopath("blank", "tmpLess") %>**/*', - '<%= combo.autopath("blank", "tmpSource") %>**/*' - ] - }] - }, - backend: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.tmp %>/cache/**/*', - '<%= combo.autopath("backend", "pub") %>**/*', - '<%= combo.autopath("backend", "tmpLess") %>**/*', - '<%= combo.autopath("backend", "tmpSource") %>**/*' - ] - }] - }, - luma: { - force: true, - files: [{ - force: true, - dot: true, - src: [ - '<%= path.tmp %>/cache/**/*', - '<%= combo.autopath("luma", "pub") %>**/*', - '<%= combo.autopath("luma", "tmpLess") %>**/*', - '<%= combo.autopath("luma", "tmpSource") %>**/*' - ] - }] - } - }, - - // Compiles Less to CSS and generates necessary files if requested - // --------------------------------------------- - less: { - options: { - sourceMap: true, - strictImports: false, - sourceMapRootpath: '/', - dumpLineNumbers: false, // use 'comments' instead false to output line comments for source - ieCompat: false - }, - backend: { - files: combo.lessFiles('backend') - }, - blank: { - files: combo.lessFiles('blank') - }, - luma: { - files: combo.lessFiles('luma') - }, - setup: { - files: { - '<%= path.css.setup %>/setup.css': "<%= path.less.setup %>/setup.less" - } - }, - documentation: { - files: { - '<%= path.doc %>/docs.css': "<%= path.doc %>/source/docs.less" - } - } - }, - - // Styles minify - // --------------------------------------------- - - cssmin: { - options: { - report: 'gzip', - keepSpecialComments: 0 - }, - setup: { - files: { - '<%= path.css.setup %>/setup.css': '<%= path.css.setup %>/setup.css' - } - } - }, - - // Styles autoprefixer - // --------------------------------------------- - - autoprefixer: { - options: { - browsers: [ - 'last 2 versions', - 'ie 9' - ] - }, - setup: { - src: '<%= path.css.setup %>/setup.css' - } - }, - - // Concatenation - // --------------------------------------------- - - concat: { - options: { - stripBanners: true, - banner: '/**\n * Copyright © <%= grunt.template.today("yyyy") %> Magento. All rights reserved.\n * See COPYING.txt for license details.\n */\n' - }, - setup: { - src: '<%= path.css.setup %>/setup.css', - dest: '<%= path.css.setup %>/setup.css' - } - }, - - - // Watches files for changes and runs tasks based on the changed files - // --------------------------------------------- - - watch: { - backend: { - files: [ - '<%= combo.autopath("backend","pub") %>/**/*.less' - ], - tasks: 'less:backend' - }, - blank: { - files: [ - '<%= combo.autopath("blank","pub") %>/**/*.less' - ], - tasks: 'less:blank' - }, - luma: { - files: [ - '<%= combo.autopath("luma","pub") %>/**/*.less' - ], - tasks: 'less:luma' - }, - setup: { - files: '<%= path.less.setup %>/**/*.less', - tasks: 'less:setup' - } - }, - - // Images optimization - imagemin: { - png: { - options: { - optimizationLevel: 7 - }, - files: [ - { - expand: true, - src: ['**/*.png'], - ext: '.png' - } - ] - }, - jpg: { - options: { - progressive: true - }, - files: [ - { - expand: true, - src: ['**/*.jpg'], - ext: '.jpg' - } - ] - }, - gif: { - files: [ - { - expand: true, - src: ['**/*.gif'], - ext: '.gif' - } - ] - }, - svg: { - options: { - use: [svgo()] - }, - files: [ - { - expand: true, - src: ['**/*.svg'], - ext: '.svg' - } - ] - } - }, - - 'mage-minify': { - legacy: { - options: { - type: 'yui-js', - tempPath: 'var/cache/', - options: ['--nomunge=true'] - }, - files: { - '<%= config.path.uglify.legacy %>': [ - 'lib/web/prototype/prototype.js', - 'lib/web/prototype/window.js', - 'lib/web/scriptaculous/builder.js', - 'lib/web/scriptaculous/effects.js', - 'lib/web/lib/ccard.js', - 'lib/web/prototype/validation.js', - 'lib/web/varien/js.js', - 'lib/web/mage/adminhtml/varienLoader.js', - 'lib/web/mage/adminhtml/tools.js' - ] - } - } - }, - - // - - styledocco: { - documentation: { - options: { - name: 'Magento UI Library', - verbose: true, - include: [ - '<%= path.doc %>/docs.css' // Todo UI: Check out JS for Styledocco - //'lib/web/jquery/jquery.min.js', - //'lib/web/jquery/jquery-ui.min', - //'<%= path.doc %>/source/js/dropdown.js' - ] - }, - files: { - '<%= path.doc %>': '<%= path.doc %>/source' - } - } - }, + }); - specRunner: { - options: { - shareDir: 'base' - }, - backend: { - options: { - port: 8000, - areaDir: 'adminhtml', - theme: 'backend' - } - }, - frontend: { - options: { - port: 3000, - areaDir: 'frontend', - theme: 'blank' - } - }, - lib: { - options: { - port: 8080 - } + _.each({ + /** + * Assembling tasks. + * ToDo UI: define default tasks. + */ + default: function () { + grunt.log.subhead('I\'m default task and at the moment I\'m empty, sorry :/'); + }, + + prod: function (component) { + if (component === 'setup') { + grunt.task.run([ + 'less:' + component, + 'autoprefixer:' + component, + 'cssmin:' + component, + 'concat:' + component + ]); + } else if (typeof component === 'undefined') { + grunt.log.subhead('Tip: Please make sure that u specify prod subtask. By default prod task do nothing'); } }, - jasmine: { - 'options': { - template: require('grunt-template-jasmine-requirejs'), - ignoreEmpty: true - }, - 'lib-unit': specRunner.configure('unit', 'lib', 8080), - 'lib-integration': specRunner.configure('integration', 'lib', 8080), - 'backend-unit': specRunner.configure('unit', 'adminhtml', 8000), - 'backend-integration': specRunner.configure('integration', 'adminhtml', 8000), - 'frontend-unit': specRunner.configure('unit', 'frontend', 3000), - 'frontend-integration': specRunner.configure('integration', 'frontend', 3000) - } - }); - - // Assembling tasks - // _____________________________________________ - - grunt.registerTask('default', function () { // ToDo UI: define default tasks - grunt.log.subhead('I\'m default task and at the moment I\'m empty, sorry :/'); - }); - - // Refresh magento frontend & backend - // --------------------------------------------- - - grunt.registerTask('refresh', [ - 'exec:all', - 'less:blank', - 'less:luma', - 'less:backend' - ]); - - // Creates build of a legacy files. - // Mostly prototype dependant libraries. - // --------------------------------------------- - - grunt.registerTask('legacy-build', [ - 'mage-minify:legacy' - ]); - - // Documentation - // --------------------------------------------- - - grunt.registerTask('documentation', [ - 'less:documentation', - 'styledocco:documentation', - 'clean:var', - 'clean:pub' - ]); - - // Production - // --------------------------------------------- - - grunt.registerTask('prod', function (component) { - if (component === 'setup') { - grunt.task.run([ - 'less:' + component, - 'autoprefixer:' + component, - 'cssmin:' + component, - 'concat:' + component - ]); - } - if (component == undefined) { - grunt.log.subhead('Tip: Please make sure that u specify prod subtask. By default prod task do nothing'); - } + /** + * Refresh magento frontend & backend. + */ + refresh: [ + 'exec:all', + 'less:blank', + 'less:luma', + 'less:backend' + ], + + /** + * Documentation + */ + documentation: [ + 'less:documentation', + 'styledocco:documentation', + 'clean:var', + 'clean:pub' + ], + + spec: [ + 'specRunner:lib', + 'specRunner:backend', + 'specRunner:frontend' + ], + + unit: [ + 'jasmine:lib-unit', + 'jasmine:backend-unit', + 'jasmine:frontend-unit' + ], + + integration: [ + 'jasmine:lib-integration', + 'jasmine:backend-integration', + 'jasmine:frontend-integration' + ], + + 'legacy-build': [ + 'mage-minify:legacy' + ] + }, function (task, name) { + grunt.registerTask(name, task); }); - - // Tests - // --------------------------------------------- - - grunt.registerTask('spec', [ - 'specRunner:lib', - 'specRunner:backend', - 'specRunner:frontend' - ]); - - grunt.registerTask('unit', [ - 'jasmine:lib-unit', - 'jasmine:backend-unit', - 'jasmine:frontend-unit' - ]); - - grunt.registerTask('integration', [ - 'jasmine:lib-integration', - 'jasmine:backend-integration', - 'jasmine:frontend-integration' - ]); }; diff --git a/dev/tools/grunt/configs/autoprefixer.json b/dev/tools/grunt/configs/autoprefixer.json new file mode 100644 index 0000000000000000000000000000000000000000..a203a65ef7ee9e37edd3df211c5c983b32654ef8 --- /dev/null +++ b/dev/tools/grunt/configs/autoprefixer.json @@ -0,0 +1,11 @@ +{ + "options": { + "browsers": [ + "last 2 versions", + "ie 9" + ] + }, + "setup": { + "src": "<%= path.css.setup %>/setup.css" + } +} \ No newline at end of file diff --git a/dev/tools/grunt/configs/clean.json b/dev/tools/grunt/configs/clean.json new file mode 100644 index 0000000000000000000000000000000000000000..aedc81f1da6af7689e93b80fd28e92ceb4e753f6 --- /dev/null +++ b/dev/tools/grunt/configs/clean.json @@ -0,0 +1,124 @@ +{ + "var": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.tmp %>/cache/**/*", + "<%= path.tmp %>/generation/**/*", + "<%= path.tmp %>/log/**/*", + "<%= path.tmp %>/maps/**/*", + "<%= path.tmp %>/page_cache/**/*", + "<%= path.tmp %>/tmp/**/*", + "<%= path.tmp %>/view/**/*", + "<%= path.tmp %>/view_preprocessed/**/*" + ] + } + ] + }, + "pub": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.pub %>frontend/**/*", + "<%= path.pub %>adminhtml/**/*" + ] + } + ] + }, + "styles": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.tmp %>/view_preprocessed/**/*", + "<%= path.tmp %>/cache/**/*", + "<%= path.pub %>frontend/**/*.less", + "<%= path.pub %>frontend/**/*.css", + "<%= path.pub %>adminhtml/**/*.less", + "<%= path.pub %>adminhtml/**/*.css" + ] + } + ] + }, + "markup": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.tmp %>/cache/**/*", + "<%= path.tmp %>/generation/**/*", + "<%= path.tmp %>/page_cache/**/*" + ] + } + ] + }, + "js": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.pub %>**/*.js", + "<%= path.pub %>**/*.html", + "<%= path.pub %>_requirejs/**/*" + ] + } + ] + }, + "blank": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.tmp %>/cache/**/*", + "<%= combo.autopath(\"blank\", \"pub\") %>**/*", + "<%= combo.autopath(\"blank\", \"tmpLess\") %>**/*", + "<%= combo.autopath(\"blank\", \"tmpSource\") %>**/*" + ] + } + ] + }, + "backend": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.tmp %>/cache/**/*", + "<%= combo.autopath(\"backend\", \"pub\") %>**/*", + "<%= combo.autopath(\"backend\", \"tmpLess\") %>**/*", + "<%= combo.autopath(\"backend\", \"tmpSource\") %>**/*" + ] + } + ] + }, + "luma": { + "force": true, + "files": [ + { + "force": true, + "dot": true, + "src": [ + "<%= path.tmp %>/cache/**/*", + "<%= combo.autopath(\"luma\", \"pub\") %>**/*", + "<%= combo.autopath(\"luma\", \"tmpLess\") %>**/*", + "<%= combo.autopath(\"luma\", \"tmpSource\") %>**/*" + ] + } + ] + } +} \ No newline at end of file diff --git a/dev/tools/grunt/configs/combo.js b/dev/tools/grunt/configs/combo.js new file mode 100644 index 0000000000000000000000000000000000000000..0f7ad1f0e884c4014426a670178640e537ba34e4 --- /dev/null +++ b/dev/tools/grunt/configs/combo.js @@ -0,0 +1,54 @@ +'use strict'; + +var theme = require('./theme'), + path = require('./path'); + +/** + * Define Combos for repetitive code. + */ +module.exports = { + collector: function (themeName) { + var cmdPlus = /^win/.test(process.platform) ? ' & ' : ' && ', + command = 'grunt --force clean:' + themeName + cmdPlus; + + command = command + 'php -f dev/tools/Magento/Tools/Webdev/less.php --' + + ' --locale=' + theme[themeName].locale + + ' --area=' + theme[themeName].area + + ' --theme=' + theme[themeName].name + + ' --files=' + theme[themeName].files.join(','); + + return command; + }, + + autopath: function (themeName) { + return path.pub + + theme[themeName].area + '/' + + theme[themeName].name + '/' + + theme[themeName].locale + '/'; + }, + + lessFiles: function (themeName) { + var lessStringArray = [], + cssStringArray = [], + lessFiles = {}, + i = 0; + + for (i; i < theme[themeName].files.length; i++) { + cssStringArray[i] = path.pub + + theme[themeName].area + '/' + + theme[themeName].name + '/' + + theme[themeName].locale + '/' + + theme[themeName].files[i] + '.css'; + + lessStringArray[i] = path.pub + + theme[themeName].area + '/' + + theme[themeName].name + '/' + + theme[themeName].locale + '/' + + theme[themeName].files[i] + '.less'; + + lessFiles[cssStringArray[i]] = lessStringArray[i]; + } + + return lessFiles; + } +}; diff --git a/dev/tools/grunt/configs/concat.json b/dev/tools/grunt/configs/concat.json new file mode 100644 index 0000000000000000000000000000000000000000..b02024c38559f756683ea589333287e3fc10b1e6 --- /dev/null +++ b/dev/tools/grunt/configs/concat.json @@ -0,0 +1,10 @@ +{ + "options": { + "stripBanners": true, + "banner": "/**\n * Copyright © <%= grunt.template.today(\"yyyy\") %> Magento. All rights reserved.\n * See COPYING.txt for license details.\n */\n" + }, + "setup": { + "src": "<%= path.css.setup %>/setup.css", + "dest": "<%= path.css.setup %>/setup.css" + } +} \ No newline at end of file diff --git a/dev/tools/grunt/configs/cssmin.json b/dev/tools/grunt/configs/cssmin.json new file mode 100644 index 0000000000000000000000000000000000000000..4c8669b07e949c256d24463b8fb2a86ed0243656 --- /dev/null +++ b/dev/tools/grunt/configs/cssmin.json @@ -0,0 +1,11 @@ +{ + "options": { + "report": "gzip", + "keepSpecialComments": 0 + }, + "setup": { + "files": { + "<%= path.css.setup %>/setup.css": "<%= path.css.setup %>/setup.css" + } + } +} \ No newline at end of file diff --git a/dev/tools/grunt/configs/exec.js b/dev/tools/grunt/configs/exec.js new file mode 100644 index 0000000000000000000000000000000000000000..02a8d7610a6e0fdb4eaf8f2475d38a5a22e0ff6c --- /dev/null +++ b/dev/tools/grunt/configs/exec.js @@ -0,0 +1,39 @@ +'use strict'; + +var combo = require('./combo'), + theme = require('./theme'); + +/** + * Execution into cmd + */ +module.exports = { + blank: { + cmd: function () { + return combo.collector('blank'); + } + }, + luma: { + cmd: function () { + return combo.collector('luma'); + } + }, + backend: { + cmd: function () { + return combo.collector('backend'); + } + }, + all: { + cmd: function () { + var command = '', + cmdPlus = /^win/.test(process.platform) ? ' & ' : ' && ', + themes = Object.keys(theme), + i = 0; + + for (i; i < themes.length; i++) { + command += combo.collector(themes[i]) + cmdPlus; + } + + return 'echo ' + command; + } + } +}; diff --git a/dev/tools/grunt/configs/imagemin.js b/dev/tools/grunt/configs/imagemin.js new file mode 100644 index 0000000000000000000000000000000000000000..5d2058ec46c116bec50086f0fd503ab90c42f442 --- /dev/null +++ b/dev/tools/grunt/configs/imagemin.js @@ -0,0 +1,46 @@ +'use strict'; + +var svgo = require('imagemin-svgo'); + +/** + * Images optimization. + */ +module.exports = { + png: { + options: { + optimizationLevel: 7 + }, + files: [{ + expand: true, + src: ['**/*.png'], + ext: '.png' + }] + }, + jpg: { + options: { + progressive: true + }, + files: [{ + expand: true, + src: ['**/*.jpg'], + ext: '.jpg' + }] + }, + gif: { + files: [{ + expand: true, + src: ['**/*.gif'], + ext: '.gif' + }] + }, + svg: { + options: { + use: [svgo()] + }, + files: [{ + expand: true, + src: ['**/*.svg'], + ext: '.svg' + }] + } +}; diff --git a/dev/tools/grunt/configs/jasmine.js b/dev/tools/grunt/configs/jasmine.js new file mode 100644 index 0000000000000000000000000000000000000000..168c4fbb0860a9b06d8dc6a6ff5e52c11e08f3b2 --- /dev/null +++ b/dev/tools/grunt/configs/jasmine.js @@ -0,0 +1,21 @@ +'use strict'; + +var path = require('path'); + +module.exports = function (grunt) { + var file = path.join(process.cwd(), 'dev/tests/js/framework/spec_runner'), + specRunner = require(file)(grunt); + + return { + options: { + template: require('grunt-template-jasmine-requirejs'), + ignoreEmpty: true + }, + 'lib-unit': specRunner.configure('unit', 'lib', 8080), + 'lib-integration': specRunner.configure('integration', 'lib', 8080), + 'backend-unit': specRunner.configure('unit', 'adminhtml', 8000), + 'backend-integration': specRunner.configure('integration', 'adminhtml', 8000), + 'frontend-unit': specRunner.configure('unit', 'frontend', 3000), + 'frontend-integration': specRunner.configure('integration', 'frontend', 3000) + }; +}; diff --git a/dev/tools/grunt/configs/less.js b/dev/tools/grunt/configs/less.js new file mode 100644 index 0000000000000000000000000000000000000000..7ed82ce739f4a7742dacf6e6e2a93fc79f4003d8 --- /dev/null +++ b/dev/tools/grunt/configs/less.js @@ -0,0 +1,35 @@ +'use strict'; + +var combo = require('./combo'); + +/** + * Compiles Less to CSS and generates necessary files if requested. + */ +module.exports = { + options: { + sourceMap: true, + strictImports: false, + sourceMapRootpath: '/', + dumpLineNumbers: false, // use 'comments' instead false to output line comments for source + ieCompat: false + }, + backend: { + files: combo.lessFiles('backend') + }, + blank: { + files: combo.lessFiles('blank') + }, + luma: { + files: combo.lessFiles('luma') + }, + setup: { + files: { + '<%= path.css.setup %>/setup.css': '<%= path.less.setup %>/setup.less' + } + }, + documentation: { + files: { + '<%= path.doc %>/docs.css': '<%= path.doc %>/source/docs.less' + } + } +}; diff --git a/dev/tools/grunt/configs/mage-minify.json b/dev/tools/grunt/configs/mage-minify.json new file mode 100644 index 0000000000000000000000000000000000000000..35eff310a850c1f7d7599e693e8490af86ff6d36 --- /dev/null +++ b/dev/tools/grunt/configs/mage-minify.json @@ -0,0 +1,24 @@ +{ + "legacy": { + "options": { + "type": "yui-js", + "tempPath": "var/cache/", + "options": [ + "--nomunge=true" + ] + }, + "files": { + "<%= path.uglify.legacy %>": [ + "lib/web/prototype/prototype.js", + "lib/web/prototype/window.js", + "lib/web/scriptaculous/builder.js", + "lib/web/scriptaculous/effects.js", + "lib/web/lib/ccard.js", + "lib/web/prototype/validation.js", + "lib/web/varien/js.js", + "lib/web/mage/adminhtml/varienLoader.js", + "lib/web/mage/adminhtml/tools.js" + ] + } + } +} \ No newline at end of file diff --git a/dev/tools/grunt/configs/path.js b/dev/tools/grunt/configs/path.js new file mode 100644 index 0000000000000000000000000000000000000000..49c08b63b0486cd4fa3cbe86ed9aa7069b201e93 --- /dev/null +++ b/dev/tools/grunt/configs/path.js @@ -0,0 +1,22 @@ +'use strict'; + +/** + * Define paths. + */ +module.exports = { + pub: 'pub/static/', + tmpLess: 'var/view_preprocessed/less/', + tmpSource: 'var/view_preprocessed/source/', + tmp: 'var', + css: { + setup: 'setup/pub/magento/setup/css' + }, + less: { + setup: 'setup/module/Magento/Setup/styles' + }, + uglify: { + legacy: 'lib/web/legacy-build.min.js' + }, + doc: 'lib/web/css/docs', + spec: 'dev/tests/js/spec' +}; diff --git a/dev/tools/grunt/configs/specRunner.json b/dev/tools/grunt/configs/specRunner.json new file mode 100644 index 0000000000000000000000000000000000000000..0d47c57e101a2b121e6ea5f0f67c87ca2191b70e --- /dev/null +++ b/dev/tools/grunt/configs/specRunner.json @@ -0,0 +1,24 @@ +{ + "options": { + "shareDir": "base" + }, + "backend": { + "options": { + "port": 8000, + "areaDir": "adminhtml", + "theme": "backend" + } + }, + "frontend": { + "options": { + "port": 3000, + "areaDir": "frontend", + "theme": "blank" + } + }, + "lib": { + "options": { + "port": 8080 + } + } +} \ No newline at end of file diff --git a/dev/tools/grunt/configs/styledocco.json b/dev/tools/grunt/configs/styledocco.json new file mode 100644 index 0000000000000000000000000000000000000000..8a75d43ac35e499b2330de1fb40750249a746092 --- /dev/null +++ b/dev/tools/grunt/configs/styledocco.json @@ -0,0 +1,14 @@ +{ + "documentation": { + "options": { + "name": "Magento UI Library", + "verbose": true, + "include": [ + "<%= path.doc %>/docs.css" + ] + }, + "files": { + "<%= path.doc %>": "<%= path.doc %>/source" + } + } +} \ No newline at end of file diff --git a/dev/tools/grunt/configs/theme.js b/dev/tools/grunt/configs/theme.js new file mode 100644 index 0000000000000000000000000000000000000000..48d166f23ea550e378ec27596f14dc21d19c5444 --- /dev/null +++ b/dev/tools/grunt/configs/theme.js @@ -0,0 +1,36 @@ +'use strict'; + +/** + * Define Themes + */ +module.exports = { + blank: { + area: 'frontend', + name: 'Magento/blank', + locale: 'en_US', + files: [ + 'css/styles-m', + 'css/styles-l' + ] + }, + luma: { + area: 'frontend', + name: 'Magento/luma', + locale: 'en_US', + files: [ + 'css/styles-m', + 'css/styles-l' + ] + }, + backend: { + area: 'adminhtml', + name: 'Magento/backend', + locale: 'en_US', + files: [ + 'css/styles-old', + 'css/styles', + 'css/pages', + 'css/admin' + ] + } +}; diff --git a/dev/tools/grunt/configs/watch.json b/dev/tools/grunt/configs/watch.json new file mode 100644 index 0000000000000000000000000000000000000000..8de170b13dc36027441944e6f9c73fe5f90f92ec --- /dev/null +++ b/dev/tools/grunt/configs/watch.json @@ -0,0 +1,24 @@ +{ + "backend": { + "files": [ + "<%= combo.autopath(\"backend\",\"pub\") %>/**/*.less" + ], + "tasks": "less:backend" + }, + "blank": { + "files": [ + "<%= combo.autopath(\"blank\",\"pub\") %>/**/*.less" + ], + "tasks": "less:blank" + }, + "luma": { + "files": [ + "<%= combo.autopath(\"luma\",\"pub\") %>/**/*.less" + ], + "tasks": "less:luma" + }, + "setup": { + "files": "<%= path.less.setup %>/**/*.less", + "tasks": "less:setup" + } +} \ No newline at end of file diff --git a/package.json b/package.json index 1fe7921b68ec9f39ea1015d1a0ee7b362cdc6d1a..0395c50b9044465e44b284d5fbb750fdcd516112 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "grunt-styledocco": "^0.1.4", "grunt-template-jasmine-requirejs": "^0.2.0", "imagemin-svgo": "^4.0.1", - "load-grunt-tasks": "^1.0.0", + "load-grunt-config": "^0.16.0", "morgan": "^1.5.0", "node-minify": "^1.0.1", "serve-static": "^1.7.1",