-
-
Save corysimmons/89f3da31548fc807ee8a48fdc80d8f89 to your computer and use it in GitHub Desktop.
Webpack config. Asset files are in assets/src/{js/scss} and they are being compiled to public/{js/css}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '../scss/admin.scss'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '../scss/app.scss'; | |
import './fileOne.js'; | |
import './fileTwo.js'; | |
import './fileThree.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "webpack-wordpress", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"build": "webpack", | |
"watch": "webpack --watch", | |
"production": "cross-env NODE_ENV=production webpack" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "git+https://github.com/itzikbenh/water.git" | |
}, | |
"author": "Isaac Ben", | |
"license": "ISC", | |
"bugs": { | |
"url": "https://github.com/itzikbenh/water/issues" | |
}, | |
"devDependencies": { | |
"autoprefixer": "^6.7.5", | |
"babel-core": "^6.23.1", | |
"babel-loader": "^6.3.2", | |
"babel-preset-es2015": "^6.13.2", | |
"bootstrap-sass": "^3.3.7", | |
"browser-sync": "^2.13.0", | |
"browser-sync-webpack-plugin": "^1.1.4", | |
"cross-env": "^3.1.4", | |
"css-loader": "^0.26.2", | |
"cssnano": "^3.10.0", | |
"extract-text-webpack-plugin": "^2.0.0", | |
"file-loader": "^0.10.1", | |
"lost": "^8.0.0", | |
"node-sass": "^4.5.0", | |
"optimize-css-assets-webpack-plugin": "^1.3.0", | |
"postcss-ant": "^2.1.1", | |
"postcss-loader": "^1.3.2", | |
"sass-loader": "^6.0.2", | |
"style-loader": "^0.13.2", | |
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony", | |
"uglifyjs-webpack-plugin": "^0.2.1", | |
"url-loader": "^0.5.8", | |
"webpack": "^2.2.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
plugins: [ | |
require('postcss-ant'), | |
require('autoprefixer') | |
] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '../scss/vendor.scss'; | |
import 'bootstrap-sass'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$icon-font-path: '../../../node_modules/bootstrap-sass/assets/fonts/bootstrap/'; | |
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
const ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); | |
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | |
const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); | |
const config = { | |
entry: { | |
app: './assets/src/js/app.js', | |
vendor: './assets/src/js/vendor.js', | |
admin: './assets/src/js/admin.js', | |
}, | |
output: { | |
filename: '/js/[name].js', | |
path: path.resolve(__dirname, 'public'), | |
}, | |
devtool: "eval", | |
module: { | |
rules: [ | |
{ | |
test: /\.scss$/, | |
exclude: /(node_modules|bower_components)/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: ['css-loader', 'postcss-loader', 'sass-loader'] | |
}), | |
}, | |
{ | |
test: /\.(woff2?|ttf|eot|svg)$/, | |
use: ['url-loader'] | |
}, | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules|bower_components)/, | |
loader: 'babel-loader', | |
query: { | |
presets: ['es2015'] | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin('/css/[name].css'), | |
new BrowserSyncPlugin({ | |
proxy: 'localhost:8888/mysite', | |
port: 3000, | |
files: [ | |
'**/*.php' | |
], | |
ghostMode: { | |
clicks: false, | |
location: false, | |
forms: false, | |
scroll: false | |
}, | |
injectChanges: true, | |
logFileChanges: true, | |
logLevel: 'debug', | |
logPrefix: 'wepback-patterns', | |
notify: true, | |
reloadDelay: 0 | |
}) | |
] | |
}; | |
//If true JS and CSS files will be minified | |
if (process.env.NODE_ENV === 'production') { | |
config.plugins.push( | |
new UglifyJSPlugin(), | |
new OptimizeCssAssetsPlugin() | |
); | |
} | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment