From 369faaa5fd4df4c723f23725d6e31c712e12a5c8 Mon Sep 17 00:00:00 2001 From: Myles Derham Date: Tue, 13 Jun 2017 11:20:18 +1200 Subject: [PATCH] Updated installer to use Laravel Mix instead of Elixir. Minor tweaks to composer. --- .gitignore | 3 +- composer.json | 17 ++++------ gulpfile.js | 24 -------------- mysite/_config/config.yml | 3 ++ package.json | 21 ++++++++---- themes/base/js/app.js | 61 ++++++++++++++++++++++++----------- themes/base/templates/Page.ss | 1 + webpack.config.js | 29 ----------------- webpack.mix.js | 23 +++++++++++++ 9 files changed, 94 insertions(+), 88 deletions(-) delete mode 100755 gulpfile.js mode change 100644 => 100755 package.json delete mode 100644 webpack.config.js create mode 100644 webpack.mix.js diff --git a/.gitignore b/.gitignore index 97880de..244b84b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ !/phpunit.xml !/gulpfile.js !/package.json -!/webpack.config.js +!/webpack.mix.js !favicon.ico *Thumbs.db *web.config @@ -32,3 +32,4 @@ *.sublime-* *.sass-cache *prepros.cfg +*mix-manifest.json diff --git a/composer.json b/composer.json index 8c3fcb0..5acb287 100755 --- a/composer.json +++ b/composer.json @@ -1,17 +1,13 @@ { "name": "plato-creative/plato-silverstripe-installer", - "description": "Custom built SilverStripe installer with Foundation.", + "description": "Custom built SilverStripe installer with Foundation", "type": "silverstripe-module", "homepage": "https://github.com/PlatoCreative/plato-silverstripe-installer", - "keywords": ["silverstripe", "installer", "plato", "creative", "foundation"], + "keywords": ["silverstripe", "installer", "plato creative"], "authors": [ { - "name": "Myles Beardsmore", - "email": "mediabeastnz@gmail.com" - }, - { - "name": "Gorrie Coe", - "email": "gorriecoe@gmail.com" + "name": "Plato Creative", + "email": "web@platocreative.co.nz" } ], "require": { @@ -35,10 +31,11 @@ "markguinn/silverstripe-email-helpers": "1.2.*", "plato-creative/silverstripe-styleguide": "1.*", "undefinedoffset/silverstripe-nocaptcha": "0.2.*", - "tractorcow/silverstripe-dynamiccache": "4.1.*" + "tractorcow/silverstripe-dynamiccache": "4.1.*", + "ryanpotter/silverstripe-cms-theme": "^1.0" }, "require-dev": { - "phpunit/PHPUnit": "~3.7" + "phpunit/PHPUnit": "~3.7@stable" }, "prefer-stable": true, "minimum-stability": "dev" diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100755 index a1df476..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,24 +0,0 @@ -/*------------------------------------------------------------------- -Required plugins --------------------------------------------------------------------*/ -var elixir = require('laravel-elixir'); - -/*------------------------------------------------------------------- -Configuration --------------------------------------------------------------------*/ - -elixir.config.assetsPath = 'themes/base'; -elixir.config.publicPath = 'themes/base'; -elixir.config.sourcemaps = true; -elixir.config.css.sass.folder = 'scss'; -elixir.config.css.autoprefix.options.browsers = ['> 1%', 'IE > 8']; - -/*------------------------------------------------------------------- -Tasks --------------------------------------------------------------------*/ - -elixir(function(mix) { - mix.sass('app.scss'); - mix.sass('editor.scss'); - mix.webpack('app.js', elixir.config.publicPath + '/js/app.min.js'); -}); diff --git a/mysite/_config/config.yml b/mysite/_config/config.yml index 2c09577..852cd16 100644 --- a/mysite/_config/config.yml +++ b/mysite/_config/config.yml @@ -24,3 +24,6 @@ SmtpMailer: password: tls: true charset: UTF-8 +LeftAndMain: + cms_menu_color: '#ffffff' + cms_menu_background: '#000000' diff --git a/package.json b/package.json old mode 100644 new mode 100755 index c72156f..9b661c9 --- a/package.json +++ b/package.json @@ -1,12 +1,21 @@ { "private": true, - "dependencies": { + "scripts": { + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch-p": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch-poll": "npm run watch -- --watch-poll", + "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + }, + "devDependencies": { + "axios": "^0.16.2", + "cross-env": "^3.2.3", "foundation-sites": "6.3.*", - "gulp": "^3.9.1", "jquery": "2.2.3", - "jquery-fancybox": "^3.1.0", - "laravel-elixir": "6.0.0-15", - "laravel-elixir-webpack-official": "^1.0.10", - "script-loader": "^0.7.0" + "jquery-match-height": "^0.7.2", + "laravel-mix": "^0.*" } } diff --git a/themes/base/js/app.js b/themes/base/js/app.js index e62bc37..4c9b210 100644 --- a/themes/base/js/app.js +++ b/themes/base/js/app.js @@ -1,26 +1,51 @@ - -// Require jQuery -window.$ = window.jQuery = require('jquery/dist/jquery.js'); -// Require Foundation +/** + * Load Plugins + * If you don't see a plugin below it might be autloaded via webpack + * Check webpack.mix.js for autoloaded plugins. + */ require('foundation-sites'); +require('jquery-match-height'); + + +/** + * We'll load the axios HTTP library which allows us to easily issue requests + * to our Laravel back-end. This library automatically handles sending the + * CSRF token as a header based on the value of the "XSRF" token cookie. + */ +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; +/** + * Next we will register the CSRF Token as a common header with Axios so that + * all outgoing HTTP requests automatically have it attached. This is just + * a simple convenience so we don't have to attach every token manually. + */ +let token = document.head.querySelector('meta[name="csrf-token"]'); +if (token) { + window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; +} else { + console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); +} -(function($) { +/** + * + * Application script + * + */ +$(function() { + // init Foundation $(document).foundation(); - $(document).ready(function() { - // google analytics - $('[data-ga-label]').each(function(){ - $(this).on('click', function() { - var $trackingName = $(this).data('ga-label'), - $tagName = $(this).prop("tagName"), - $action = 'click'; - if($tagName=='input'){ - $action = 'submit'; - } - ga('send', 'event', 'button', $action, $trackingName); - }); + // google analytics + $('[data-ga-label]').each(function(){ + $(this).on('click', function() { + var $trackingName = $(this).data('ga-label'), + $tagName = $(this).prop("tagName"), + $action = 'click'; + if($tagName=='input'){ + $action = 'submit'; + } + ga('send', 'event', 'button', $action, $trackingName); }); }); -}(jQuery)); +}); diff --git a/themes/base/templates/Page.ss b/themes/base/templates/Page.ss index 128dbe8..fe74fd9 100755 --- a/themes/base/templates/Page.ss +++ b/themes/base/templates/Page.ss @@ -6,6 +6,7 @@ + $MetaTags(false) <% require themedCSS('app') %> diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 313e622..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,29 +0,0 @@ -const webpack = require('webpack'); -const path = require('path'); - -const isProduction = process.env.NODE_ENV === 'production'; - -module.exports = { - - resolve: { - extensions: ['', '.js', '.jsx'], - }, - - devtool: isProduction ? null : 'source-map', - - plugins: [ - - isProduction ? new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false, - }, - }) : null, - - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: '\'' + process.env.NODE_ENV + '\'', - }, - }), - - ].filter(plugin => plugin), -}; diff --git a/webpack.mix.js b/webpack.mix.js new file mode 100644 index 0000000..f66b058 --- /dev/null +++ b/webpack.mix.js @@ -0,0 +1,23 @@ +/*------------------------------------------------------------------- +Required plugins +-------------------------------------------------------------------*/ +const { mix } = require('laravel-mix'); + +/*------------------------------------------------------------------- +Tasks +-------------------------------------------------------------------*/ +mix.autoload({ + 'jquery': ['$', 'jQuery', 'window.jQuery'], + 'axios': ['window.axios'] +}) +.js('themes/base/js/app.js', 'themes/base/js/app.min.js').sourceMaps() +.sass('themes/base/scss/app.scss', 'themes/base/css/').options({ + processCssUrls: false +}) +.sass('themes/base/scss/editor.scss', 'themes/base/css/'); + +// BrowserSync - e.g. "localhost/mysite.com" +mix.browserSync({ + proxy: 'localhost/[YOURSITENAME.CO.NZ]', + files: ["themes/base/css/*", "themes/base/js/app.min.js", "themes/base/templates/*.ss", "themes/base/templates/*/*.ss"] +});