Created
February 18, 2019 18:04
-
-
Save kyle-ssg/57b6c108cc267e64a4338e0f83a7cc82 to your computer and use it in GitHub Desktop.
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
// webpack.config.dev.js | |
const webpack = require('webpack'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const path = require('path'); | |
const whitelabel = typeof process.env.WHITELABEL === 'undefined' ? false : process.env.WHITELABEL; | |
const styles = whitelabel ? path.join(__dirname, `../web/styles/whitelabel/${process.env.WHITELABEL}`) : path.join(__dirname, '../web/styles'); | |
module.exports = { | |
devtool: 'cheap-module-eval-source-map', | |
mode: 'development', | |
entry: [ | |
'webpack-hot-middleware/client?reload=false', | |
'./web/main.js', | |
], | |
devServer: { | |
outputPath: __dirname, | |
}, | |
output: { | |
path: path.join(__dirname, '../build'), | |
filename: '[name].js', | |
}, | |
externals: { | |
// require('jquery') is external and available | |
// on the global var jQuery | |
'jquery': 'jQuery', | |
}, | |
resolve: { | |
alias: { | |
styles, | |
}, | |
}, | |
plugins: require('./plugins').concat([ | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.DefinePlugin({ | |
__DEV__: true, | |
whitelabel: JSON.stringify(process.env.WHITELABEL), | |
}), | |
new webpack.NoEmitOnErrorsPlugin(), | |
new webpack.ProvidePlugin({ | |
$: 'jquery', | |
jQuery: 'jquery', | |
jquery: 'jquery', | |
}), | |
]).concat(require('./pages').map((page) => { | |
console.log(page); | |
return new HtmlWebpackPlugin({ | |
filename: `${page}.html`, // output | |
template: `./web/${page}.html`, // template to use | |
}); | |
})), | |
module: { | |
rules: require('./loaders') | |
.concat([ | |
{ | |
test: /\.scss$/, | |
use: [{ | |
loader: 'style-loader', | |
options: { | |
sourceMap: true, | |
convertToAbsoluteUrls: false, | |
}, | |
}, | |
{ | |
loader: 'css-loader', | |
options: { | |
importLoaders: 1, | |
sourceMap: true, | |
}, | |
}, { | |
loader: 'sass-loader', | |
options: { | |
sourceMap: true, | |
}, | |
}], | |
}, | |
]), | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment