Skip to content

Commit

Permalink
Squashing asset pipeline bugs and other stuff
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
QWp6t committed Aug 13, 2016
1 parent 447c24d commit 4d58f88
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"root": true,
"extends": "eslint:recommended",
"globals": {
"wp": true,
"wp": true
},
"env": {
"browser": true,
Expand Down
9 changes: 5 additions & 4 deletions assets/scripts/main.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
3 changes: 3 additions & 0 deletions assets/styles/common/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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';
1 change: 1 addition & 0 deletions assets/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// Import npm dependencies
@import "~bootstrap/scss/bootstrap";
@import "~font-awesome/scss/font-awesome";

@import "common/global";
@import "components/buttons";
Expand Down
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand All @@ -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"
}
}
16 changes: 8 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,7 +53,7 @@ var assetsPluginProcessOutput = function (assets) {
}
}
return JSON.stringify(results);
}
};

/**
* Loop through webpack entry
Expand All @@ -80,7 +80,7 @@ var addHotMiddleware = function (entry) {
}
}
return results;
}
};

webpackConfig = {
context: path.resolve(config.context),
Expand All @@ -94,7 +94,7 @@ webpackConfig = {
preLoaders: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
include: path.resolve('assets'),
loader: 'eslint'
}
],
Expand All @@ -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,
Expand All @@ -141,15 +141,15 @@ webpackConfig = {
{
test: /\.(ttf|eot|svg)(\?.*)?$/,
loader: 'file?' + qs.stringify({
name: '[path][name].[ext]'
name: 'fonts/[name]_[md5:hash:hex:8].[ext]'
})
},
{
test: /\.woff(2)?(\?.*)?$/,
loader: 'url?' + qs.stringify({
limit: 10000,
mimetype: "application/font-woff",
name: "[path][name].[ext]"
name: "fonts/[name]_[md5:hash:hex:8].[ext]"
})
}
]
Expand Down

0 comments on commit 4d58f88

Please sign in to comment.