2018-10-28 22:12:33 +00:00
|
|
|
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')
|
2018-10-28 22:12:33 +00:00
|
|
|
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: {
|
2018-11-11 03:46:50 +00:00
|
|
|
login: './assets/js/login.js',
|
2019-02-24 21:27:24 +00:00
|
|
|
index: './assets/js/index.js',
|
|
|
|
admin: './assets/js/admin.js'
|
2018-10-29 23:56:18 +00:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, '/.tmp/public'),
|
2019-02-24 21:27:24 +00:00
|
|
|
filename: '[name].bundle.js',
|
|
|
|
publicPath: '/'
|
2018-10-29 23:56:18 +00:00
|
|
|
},
|
|
|
|
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',
|
2019-02-24 21:27:24 +00:00
|
|
|
// links: mode === 'production' ? [{ rel: 'stylesheet', type: 'text/css', href: '/login.css' }] : [],
|
2018-11-11 03:46:50 +00:00
|
|
|
filename: path.join(__dirname, '/.tmp/public/login.html'),
|
|
|
|
chunks: ['login']
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
2019-02-03 19:16:02 +00:00
|
|
|
template: 'assets/templates/index.html',
|
2019-02-24 21:27:24 +00:00
|
|
|
// links: mode === 'production' ? [{ rel: 'stylesheet', type: 'text/css', href: '/index.css' }] : [],
|
2019-02-03 19:16:02 +00:00
|
|
|
filename: path.join(__dirname, '/.tmp/public/index.html'),
|
|
|
|
chunks: ['index']
|
2018-10-29 23:56:18 +00:00
|
|
|
}),
|
2019-02-24 21:27:24 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: 'assets/templates/admin.html',
|
|
|
|
// links: mode === 'production' ? [{ rel: 'stylesheet', type: 'text/css', href: '/admin.css' }] : [],
|
|
|
|
filename: path.join(__dirname, '/.tmp/public/admin.html'),
|
|
|
|
chunks: ['admin']
|
|
|
|
}),
|
2018-10-29 23:56:18 +00:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: '[name].css'
|
|
|
|
}),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify(mode)
|
|
|
|
})
|
2019-02-03 19:16:02 +00:00
|
|
|
],
|
|
|
|
devServer: {
|
|
|
|
historyApiFallback: true,
|
|
|
|
disableHostCheck: true,
|
|
|
|
port: 8080
|
|
|
|
}
|
2018-10-29 23:56:18 +00:00
|
|
|
}
|
2018-10-29 19:31:00 +00:00
|
|
|
}
|