From b82d143af91456d2ba3be362f9c2eca846c76968 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 16 Nov 2017 16:50:33 -0500 Subject: [PATCH] fixing permissions and adding webpack config testing webpack config for sass files, they seem to work, fixed directory perms --- .gitignore | 1 + controllers/admin.php | 2 +- dist/bundle.js | 126 +++++++++++++++++++++++++++++++ dist/index.css | 1 + package.json | 27 +++++++ css/index.css => scss/_main.scss | 0 scss/app.scss | 1 + webpack.config.js | 40 ++++++++++ 8 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 dist/bundle.js create mode 100644 dist/index.css create mode 100644 package.json rename css/index.css => scss/_main.scss (100%) create mode 100644 scss/app.scss create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index 9acdb21..743e6f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ misc/smarty/** +node_modules diff --git a/controllers/admin.php b/controllers/admin.php index e0370d5..a3cb092 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -228,7 +228,7 @@ class glmProtoAdmin // A simple set of styles for things I haven't found as a WordPress // default yet wp_register_style('glmProtoIndexStyle', - GLM_PROTO_PLUGIN_URL . 'css/index.css'); + GLM_PROTO_PLUGIN_URL . 'dist/index.css'); wp_enqueue_style('glmProtoIndexStyle'); } diff --git a/dist/bundle.js b/dist/bundle.js new file mode 100644 index 0000000..9bec120 --- /dev/null +++ b/dist/bundle.js @@ -0,0 +1,126 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(1); +module.exports = __webpack_require__(2); + + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + + +// Use media uploaded for all file/image uploads +jQuery(document).ready(function($){ + + var custom_uploader; + + $('.glm-protp-upload-button').click(function(e) { + + e.preventDefault(); + + var id = $(this).attr('data-id'); + + //If the uploader object has already been created, reopen the dialog + if (custom_uploader) { + custom_uploader.open(); + return; + } + + //Extend the wp.media object + var custom_uploader = wp.media.frames.file_frame = wp.media({ + title: 'Choose the desired image below or select "Upload Files" to select a new image.', + button: { + text: 'Choose Image' + }, + multiple: false + }); + + //When a file is selected, grab the URL and set it as the text field's value + custom_uploader.on('select', function() { + attachment = custom_uploader.state().get('selection').first().toJSON(); + $('#' + id).val(attachment.url); + }); + + //Open the uploader dialog + custom_uploader.open(); + + }); + + +}); + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + +// removed by extract-text-webpack-plugin + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/dist/index.css b/dist/index.css new file mode 100644 index 0000000..8ee65e7 --- /dev/null +++ b/dist/index.css @@ -0,0 +1 @@ +.glm-proto-error,.glm-proto-required{color:red} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4445b7a --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "glm-prototypes", + "version": "1.0.0", + "description": "=== Gaslight Media Prototype Management === Contributors: cscott@gaslightmedia.com Donate link: http://www.gaslightmedia.com Tags: Gaslight Media,Plugin,Prototypes Requires at least: 4.0 Tested up to: 4.0.1 Stable tag: 1.0 License: Commercial License URI: http://www.gaslightmedia.com/plugin-license/", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build": "webpack" + }, + "repository": { + "type": "git", + "url": "git@cvs2:WP-Plugins/GlmPrototypes" + }, + "author": "", + "license": "ISC", + "dependencies": { + "css-loader": "^0.28.7", + "extract-text-webpack-plugin": "^3.0.2", + "node-sass": "^4.6.1", + "optimize-css-assets-webpack-plugin": "^3.2.0", + "sass-loader": "^6.0.6", + "webpack": "^3.8.1" + }, + "devDependencies": { + "webpack-concat-plugin": "^1.4.2" + } +} diff --git a/css/index.css b/scss/_main.scss similarity index 100% rename from css/index.css rename to scss/_main.scss diff --git a/scss/app.scss b/scss/app.scss new file mode 100644 index 0000000..a93cc06 --- /dev/null +++ b/scss/app.scss @@ -0,0 +1 @@ +@import "main"; \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..e32261d --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,40 @@ +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); +const webpack = require('webpack'); +const ConcatPlugin = require('webpack-concat-plugin'); + +module.exports = { + entry: ['./js/index.js','./scss/app.scss'], + output: { + path: __dirname + '/dist', + filename: 'bundle.js' + }, + module: { + rules: [ + /* + your other rules for JavaScript transpiling go in here + */ + { // regular css files + test: /\.css$/, + use: ExtractTextPlugin.extract({ + use: 'css-loader?importLoaders=1', + }), + }, + { // sass / scss loader for webpack + test: /\.(sass|scss)$/, + use: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) + } + ], + }, + plugins: [ + new ExtractTextPlugin({ // define where to save the file + filename: 'index.css', + allChunks: true, + }), + new OptimizeCssAssetsPlugin({ + assetNameRegExp: /\.css$/, + cssProcessorOptions: { discardComments: { removeAll: true } } + }), + ], + watch: true +} \ No newline at end of file -- 2.17.1