fixing permissions and adding webpack config develop
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 16 Nov 2017 21:50:33 +0000 (16:50 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 16 Nov 2017 21:50:33 +0000 (16:50 -0500)
testing webpack config for sass files, they seem to work, fixed directory
perms

.gitignore
controllers/admin.php
css/index.css [deleted file]
dist/bundle.js [new file with mode: 0644]
dist/index.css [new file with mode: 0644]
package.json [new file with mode: 0644]
scss/_main.scss [new file with mode: 0644]
scss/app.scss [new file with mode: 0644]
webpack.config.js [new file with mode: 0644]

index 9acdb21..743e6f4 100644 (file)
@@ -1 +1,2 @@
 misc/smarty/**
+node_modules
index e0370d5..a3cb092 100644 (file)
@@ -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/css/index.css b/css/index.css
deleted file mode 100644 (file)
index c0bd6e9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-.glm-proto-required {
-    color: red;
-}
-
-.glm-proto-error {
-    color: red;
-}
\ No newline at end of file
diff --git a/dist/bundle.js b/dist/bundle.js
new file mode 100644 (file)
index 0000000..9bec120
--- /dev/null
@@ -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 (file)
index 0000000..8ee65e7
--- /dev/null
@@ -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 (file)
index 0000000..4445b7a
--- /dev/null
@@ -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/scss/_main.scss b/scss/_main.scss
new file mode 100644 (file)
index 0000000..c0bd6e9
--- /dev/null
@@ -0,0 +1,7 @@
+.glm-proto-required {
+    color: red;
+}
+
+.glm-proto-error {
+    color: red;
+}
\ No newline at end of file
diff --git a/scss/app.scss b/scss/app.scss
new file mode 100644 (file)
index 0000000..a93cc06
--- /dev/null
@@ -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 (file)
index 0000000..e32261d
--- /dev/null
@@ -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