From 4d58f88166b5c1efd78f15ef5f1fbb2ca5f2e344 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sat, 13 Aug 2016 07:37:14 -0700 Subject: [PATCH] Squashing asset pipeline bugs and other stuff 1. Update dependencies - Add font-awesome as dependency - Switch to Bootstrap 4 dev branch - Remove eslint airbnb style (we're not using it) 2. Imported images and fonts should go into dist/images and dist/fonts, respectively 3. Only lint our own code, not external code (fixes #1633) --- .eslintrc | 2 +- assets/scripts/main.js | 9 +++++---- assets/styles/common/_variables.scss | 3 +++ assets/styles/main.scss | 1 + package.json | 14 ++++++-------- webpack.config.js | 16 ++++++++-------- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.eslintrc b/.eslintrc index 30a5994..56260bd 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,7 +2,7 @@ "root": true, "extends": "eslint:recommended", "globals": { - "wp": true, + "wp": true }, "env": { "browser": true, diff --git a/assets/scripts/main.js b/assets/scripts/main.js index 7ef154e..48e9a3f 100644 --- a/assets/scripts/main.js +++ b/assets/scripts/main.js @@ -1,12 +1,13 @@ -import $ from 'jquery'; +// import external dependencies +import 'jquery' +import 'bootstrap/dist/js/bootstrap' + +// import local dependencies import Router from './util/router'; import common from './routes/Common'; import home from './routes/Home'; import about_us from './routes/About'; -// Import npm dependencies -import 'bootstrap/dist/js/bootstrap'; - // Use this variable to set up the common and page specific functions. If you // rename this variable, you will also need to rename the namespace below. const routes = { diff --git a/assets/styles/common/_variables.scss b/assets/styles/common/_variables.scss index 3a1ae7a..72048e1 100644 --- a/assets/styles/common/_variables.scss +++ b/assets/styles/common/_variables.scss @@ -5,3 +5,6 @@ $sidebar-sm-columns: 4; // Colors $brand-primary: #27ae60; + +// Font Awesome | see: http://fontawesome.io/get-started/ +$fa-font-path: '~font-awesome/fonts'; diff --git a/assets/styles/main.scss b/assets/styles/main.scss index e08d453..d2e5cbc 100644 --- a/assets/styles/main.scss +++ b/assets/styles/main.scss @@ -2,6 +2,7 @@ // Import npm dependencies @import "~bootstrap/scss/bootstrap"; +@import "~font-awesome/scss/font-awesome"; @import "common/global"; @import "components/buttons"; diff --git a/package.json b/package.json index 9e31643..fac4256 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ "build:production": "webpack -p --progress --release", "build": "webpack -d --progress", "watch": "node watch.js --watch", - "lint": "eslint -c .eslintrc assets/scripts watch.js webpack.config.js", - "install": "composer install" + "lint": "eslint -c .eslintrc assets/scripts watch.js webpack.config.js" }, "engines": { "node": ">=4" @@ -34,15 +33,15 @@ "babel-core": "^6.7.4", "babel-eslint": "^6.0.0", "babel-loader": "^6.2.4", - "babel-preset-es2015": "^6.1.18", + "babel-preset-es2015": "^6.13.2", "babel-register": "^6.5.2", + "babel-runtime": "^6.5.0", "body-parser": "^1.14.1", "browser-sync": "^2.11.2", "clean-webpack-plugin": "^0.1.8", "css-loader": "^0.23.1", "cssnano": "^3.5.2", "eslint": "^3.2.2", - "eslint-config-airbnb": "^10.0.0", "eslint-loader": "^1.3.0", "eslint-plugin-react": "^6.0.0", "extract-text-webpack-plugin": "^1.0.1", @@ -66,9 +65,8 @@ "webpack-hot-middleware": "^2.10.0" }, "dependencies": { - "babel-runtime": "^6.5.0", - "bootstrap": "^4.0.0-alpha.3", - "jquery": "^2.1.4", - "tether": "^1.2.0" + "bootstrap": "github:twbs/bootstrap#v4-dev", + "font-awesome": "^4.6.3", + "jquery": "^1.12.4" } } diff --git a/webpack.config.js b/webpack.config.js index 5b44294..5a36613 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,8 +22,8 @@ var scriptsFilename = (argv.release) ? 'scripts/[name]_[hash].js' : 'scripts/[na jsLoader = { test: /\.js$/, - exclude: /(node_modules|bower_components)/, - loaders: [ 'babel?presets[]=es2015&cacheDirectory' ] + exclude: [ /(node_modules|bower_components)(?![/|\\](bootstrap|foundation-sites))/ ], + loaders: [ 'babel?presets[]='+path.resolve('./node_modules/babel-preset-es2015')+'&cacheDirectory' ] }; if (argv.watch) { // '--watch' to add monkey-hot @@ -53,7 +53,7 @@ var assetsPluginProcessOutput = function (assets) { } } return JSON.stringify(results); -} +}; /** * Loop through webpack entry @@ -80,7 +80,7 @@ var addHotMiddleware = function (entry) { } } return results; -} +}; webpackConfig = { context: path.resolve(config.context), @@ -94,7 +94,7 @@ webpackConfig = { preLoaders: [ { test: /\.js?$/, - exclude: /(node_modules|bower_components)/, + include: path.resolve('assets'), loader: 'eslint' } ], @@ -120,7 +120,7 @@ webpackConfig = { test: /\.(png|jpg|jpeg|gif)(\?.*)?$/, loaders: [ 'file?' + qs.stringify({ - name: '[path][name].[ext]' + name: 'images/[name]_[md5:hash:hex:8].[ext]' }), 'image-webpack?' + JSON.stringify({ bypassOnDebug:true, @@ -141,7 +141,7 @@ webpackConfig = { { test: /\.(ttf|eot|svg)(\?.*)?$/, loader: 'file?' + qs.stringify({ - name: '[path][name].[ext]' + name: 'fonts/[name]_[md5:hash:hex:8].[ext]' }) }, { @@ -149,7 +149,7 @@ webpackConfig = { loader: 'url?' + qs.stringify({ limit: 10000, mimetype: "application/font-woff", - name: "[path][name].[ext]" + name: "fonts/[name]_[md5:hash:hex:8].[ext]" }) } ]