river-of-ebooks/webpack.config.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

const HtmlWebpackPlugin = require('html-webpack-plugin')
2018-10-29 19:31:00 +00:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
2018-10-29 23:56:18 +00:00
const webpack = require('webpack')
const path = require('path')
2018-10-28 20:42:38 +00:00
2018-10-29 23:56:18 +00:00
module.exports = (env, argv) => {
const mode = argv.mode || 'development'
return {
mode: mode || 'development',
entry: {
login: './assets/js/login.js'
},
output: {
path: path.join(__dirname, '/.tmp/public'),
filename: '[name].bundle.js'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.jsx?$/,
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [
mode !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'assets/templates/login.html',
links: mode === 'production' ? [{ rel: 'stylesheet', type: 'text/css', href: 'login.css' }] : [],
filename: path.join(__dirname, '/.tmp/public/login.html')
}),
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(mode)
})
2018-10-28 20:42:38 +00:00
]
2018-10-29 23:56:18 +00:00
}
2018-10-29 19:31:00 +00:00
}