2021-01-20 16:31:34 +01:00
|
|
|
/*
|
|
|
|
* Development assets generation
|
|
|
|
*/
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
//const autoprefixer = require('autoprefixer');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const { merge } = require('webpack-merge');
|
2021-01-31 10:33:45 +01:00
|
|
|
|
2021-01-20 16:31:34 +01:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2021-01-31 10:33:45 +01:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2021-01-20 16:31:34 +01:00
|
|
|
|
|
|
|
const common = require('./webpack.config.common.js');
|
|
|
|
const commonVariables = require('./webpack.configuration');
|
|
|
|
const conf = commonVariables.configuration;
|
|
|
|
|
|
|
|
const IP = process.env.IP || conf.HOSTNAME;
|
|
|
|
const PORT = process.env.PORT || conf.PORT;
|
|
|
|
|
2021-01-25 11:10:03 +01:00
|
|
|
const UIInfo = require('./package.json');
|
2021-01-31 10:57:40 +01:00
|
|
|
const UIVERSION = JSON.stringify(UIInfo.version);
|
2021-01-31 11:31:35 +01:00
|
|
|
const UIMetaInfo = require('./node_modules/@a2nt/meta-lightbox-react/package.json');
|
2021-01-20 16:31:34 +01:00
|
|
|
|
2021-01-31 10:57:40 +01:00
|
|
|
const NODE_ENV = 'development'; //conf.NODE_ENV || process.env.NODE_ENV;
|
2021-01-31 10:33:45 +01:00
|
|
|
const COMPRESS = NODE_ENV === 'production' ? true : false;
|
|
|
|
|
|
|
|
console.log('NODE_ENV: ' + NODE_ENV);
|
|
|
|
console.log('COMPRESS: ' + COMPRESS);
|
|
|
|
console.log('WebP images: ' + conf['webp']);
|
|
|
|
|
2021-01-20 16:31:34 +01:00
|
|
|
const config = merge(common, {
|
|
|
|
mode: 'development',
|
|
|
|
|
|
|
|
entry: {
|
2021-01-31 10:33:45 +01:00
|
|
|
/*hot: [
|
2021-01-20 16:31:34 +01:00
|
|
|
'react-hot-loader/patch',
|
2021-01-31 10:33:45 +01:00
|
|
|
'webpack-dev-server/?https://' + conf.HOSTNAME + ':' + conf.PORT,
|
2021-01-20 16:31:34 +01:00
|
|
|
'webpack/hot/only-dev-server',
|
2021-01-31 10:33:45 +01:00
|
|
|
],*/
|
2021-01-20 16:31:34 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname),
|
|
|
|
filename: '[name].js',
|
|
|
|
// necessary for HMR to know where to load the hot update chunks
|
|
|
|
publicPath: 'https://' + conf.HOSTNAME + ':' + conf.PORT + '/',
|
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
//exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
2021-01-31 10:33:45 +01:00
|
|
|
presets: [
|
|
|
|
'@babel/preset-env',
|
|
|
|
'@babel/react',
|
|
|
|
{
|
|
|
|
plugins: ['@babel/plugin-proposal-class-properties'],
|
|
|
|
},
|
|
|
|
], //Preset used for env setup
|
2021-01-20 16:31:34 +01:00
|
|
|
plugins: [['@babel/transform-react-jsx']],
|
|
|
|
cacheDirectory: true,
|
2021-01-31 10:33:45 +01:00
|
|
|
cacheCompression: true,
|
2021-01-20 16:31:34 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s?css$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: !COMPRESS,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'resolve-url-loader',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'url-loader',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name(file) {
|
|
|
|
return 'public/[path][name].[ext]';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
$: 'jquery',
|
|
|
|
jQuery: 'jquery',
|
|
|
|
'window.jQuery': 'jquery',
|
|
|
|
Popper: ['popper.js', 'default'],
|
|
|
|
Util: 'exports-loader?Util!bootstrap/js/dist/util',
|
|
|
|
Alert: 'exports-loader?Alert!bootstrap/js/dist/alert',
|
|
|
|
Button: 'exports-loader?Button!bootstrap/js/dist/button',
|
|
|
|
Carousel: 'exports-loader?Carousel!bootstrap/js/dist/carousel',
|
|
|
|
Collapse: 'exports-loader?Collapse!bootstrap/js/dist/collapse',
|
|
|
|
Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown',
|
|
|
|
Modal: 'exports-loader?Modal!bootstrap/js/dist/modal',
|
|
|
|
Tooltip: 'exports-loader?Tooltip!bootstrap/js/dist/tooltip',
|
|
|
|
Popover: 'exports-loader?Popover!bootstrap/js/dist/popover',
|
|
|
|
Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/dist/scrollspy',
|
|
|
|
Tab: 'exports-loader?Tab!bootstrap/js/dist/tab',
|
|
|
|
}),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
UINAME: JSON.stringify(UIInfo.name),
|
2021-01-31 10:57:40 +01:00
|
|
|
UIVERSION: UIVERSION,
|
2021-01-20 16:31:34 +01:00
|
|
|
UIAUTHOR: JSON.stringify(UIInfo.author),
|
2021-01-31 10:57:40 +01:00
|
|
|
UIMetaNAME: JSON.stringify(UIMetaInfo.name),
|
|
|
|
UIMetaVersion: JSON.stringify(UIMetaInfo.version),
|
2021-01-20 16:31:34 +01:00
|
|
|
}),
|
2021-01-31 10:33:45 +01:00
|
|
|
//new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
publicPath: '',
|
|
|
|
template: path.join(conf.APPDIR, conf.SRC, 'index.html'),
|
|
|
|
templateParameters: {
|
|
|
|
NODE_ENV: NODE_ENV,
|
|
|
|
REACT_SCRIPTS:
|
|
|
|
NODE_ENV === 'production'
|
|
|
|
? '<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script><script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>'
|
|
|
|
: '<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script><script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>',
|
|
|
|
},
|
|
|
|
}),
|
2021-01-20 16:31:34 +01:00
|
|
|
],
|
|
|
|
|
|
|
|
devServer: {
|
|
|
|
host: IP,
|
|
|
|
port: PORT,
|
2021-01-31 10:33:45 +01:00
|
|
|
historyApiFallback: false,
|
2021-01-20 16:31:34 +01:00
|
|
|
//hot: true,
|
|
|
|
/*clientLogLevel: 'info',
|
|
|
|
disableHostCheck: true,
|
|
|
|
contentBase: [
|
|
|
|
path.resolve(__dirname, 'public'),
|
|
|
|
path.resolve(__dirname, 'public', 'resources'),
|
|
|
|
path.resolve(__dirname, 'public', 'resources', conf.APPDIR, conf.DIST),
|
|
|
|
'node_modules',
|
|
|
|
],*/
|
|
|
|
//watchContentBase: true,
|
|
|
|
overlay: {
|
|
|
|
warnings: true,
|
|
|
|
errors: true,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
'Access-Control-Allow-Origin': '*',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = config;
|