Skip to content

Instantly share code, notes, and snippets.

@macouella
Created May 9, 2018 21:41
Show Gist options
  • Save macouella/b866e3935cecd53bdd45128f9922fe49 to your computer and use it in GitHub Desktop.
Save macouella/b866e3935cecd53bdd45128f9922fe49 to your computer and use it in GitHub Desktop.
JM EXample
const path = require('path');
const pathConfig = require('./path-config.json');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const opn = require('opn');
module.exports = {
html: false,
ghPages: false,
images: true,
fonts: true,
static: true,
svgSprite: true,
stylesheets: true,
browserSync: {
port: 5605,
cors: true,
proxy: {
target: pathConfig.browserSync.proxyTarget,
proxyReq: [
function(proxyReq) {
proxyReq.setHeader(
'host',
pathConfig.host.replace(/^https?:\/\//i, '')
);
// grabone authentication requires proper host header to be set
proxyReq.setHeader('Access-Control-Allow-Origin', '*');
}
]
},
files: pathConfig.browserSync.files.map(fileGlob =>
path.join(process.env.PWD, fileGlob)
),
open: false,
online: false,
host: pathConfig.host
},
javascripts: {
entry: {
min: ['old.js'],
index: ['app.js'],
api_menu: ['api/menu.js'],
admin: ['admin.js']
},
provide: {
$: 'jquery',
jQuery: 'jquery'
},
publicPath: '/static/js',
loaders: [
{
test: /\.modernizrrc.js$/,
use: ['modernizr-loader']
},
{
test: /\.modernizrrc(\.json)?$/,
use: ['modernizr-loader', 'json-loader']
}
],
customizeWebpackConfig: (webpackConfig, env, webpack) => {
if (!webpackConfig.resolve.alias) webpackConfig.resolve.alias = {};
webpackConfig.resolve.alias.modernizr$ = path.resolve(
__dirname,
'..',
'.modernizrrc'
);
return webpackConfig;
},
development: {
plugins: webpack => {
return [new BundleAnalyzerPlugin()];
}
}
},
additionalTasks: {
initialize(gulp, PATH_CONFIG, TASK_CONFIG) {
gulp.task('openBrowser', function() {
console.log(PATH_CONFIG);
setTimeout(function() {
opn(PATH_CONFIG.host);
}, 1000);
});
},
development: {
postbuild: ['openBrowser']
}
},
production: {
rev: false
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment