2021-01-20 16:31:34 +01:00
|
|
|
/*
|
|
|
|
* Development assets generation
|
|
|
|
*/
|
2021-05-03 19:00:50 +02:00
|
|
|
const common = require('./webpack.config.common.js');
|
|
|
|
const conf = common.configuration;
|
2021-01-20 16:31:34 +01:00
|
|
|
|
|
|
|
const path = require('path');
|
2021-05-03 19:00:50 +02:00
|
|
|
const fs = require('fs');
|
2021-02-21 11:42:04 +01:00
|
|
|
|
2021-01-20 16:31:34 +01:00
|
|
|
//const autoprefixer = require('autoprefixer');
|
|
|
|
const webpack = require('webpack');
|
2021-08-04 01:12:53 +02:00
|
|
|
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 IP = process.env.IP || conf.HOSTNAME;
|
|
|
|
const PORT = process.env.PORT || conf.PORT;
|
|
|
|
|
2021-08-11 19:17:10 +02:00
|
|
|
let plugins = common.plugins;
|
2021-02-21 11:42:04 +01:00
|
|
|
|
|
|
|
const indexPath = path.join(__dirname, conf.APPDIR, conf.SRC, 'index.html');
|
2021-05-03 19:00:50 +02:00
|
|
|
if (fs.existsSync(indexPath)) {
|
|
|
|
plugins.push(
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
publicPath: '',
|
|
|
|
template: path.join(conf.APPDIR, conf.SRC, 'index.html'),
|
|
|
|
templateParameters: {
|
2021-08-11 19:17:10 +02:00
|
|
|
NODE_ENV: 'development',
|
2021-05-03 19:00:50 +02:00
|
|
|
GRAPHQL_URL: conf['GRAPHQL_URL'],
|
|
|
|
STATIC_URL: conf['STATIC_URL'],
|
2021-08-11 19:17:10 +02:00
|
|
|
REACT_SCRIPTS: '<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-05-03 19:00:50 +02:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
);
|
2021-02-21 11:42:04 +01:00
|
|
|
}
|
2021-01-31 10:33:45 +01:00
|
|
|
|
2021-05-03 19:00:50 +02:00
|
|
|
const config = merge(common.webpack, {
|
|
|
|
entry: {
|
|
|
|
/*hot: [
|
|
|
|
'react-hot-loader/patch',
|
|
|
|
'webpack-dev-server/?https://' + conf.HOSTNAME + ':' + conf.PORT,
|
|
|
|
'webpack/hot/only-dev-server',
|
|
|
|
],*/
|
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname),
|
|
|
|
filename: '[name].js',
|
|
|
|
// necessary for HMR to know where to load the hot update chunks
|
2021-08-11 19:17:10 +02:00
|
|
|
publicPath: `http${conf['HTTPS'] ? 's' : ''}://${conf['HOSTNAME']}:${conf.PORT}/`,
|
2021-05-03 19:00:50 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [{
|
2021-08-04 01:12:53 +02:00
|
|
|
test: /\.jsx?$/,
|
|
|
|
//exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: '@sucrase/webpack-loader', //'babel-loader',
|
|
|
|
options: {
|
2021-08-11 19:17:10 +02:00
|
|
|
transforms: ['jsx'],
|
2021-08-04 01:12:53 +02:00
|
|
|
/*presets: [
|
|
|
|
'@babel/preset-env',
|
|
|
|
'@babel/react',
|
|
|
|
{
|
|
|
|
plugins: [
|
|
|
|
'@babel/plugin-proposal-class-properties',
|
|
|
|
'@babel/plugin-syntax-top-level-await',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
], //Preset used for env setup
|
|
|
|
plugins: [
|
|
|
|
['@babel/transform-react-jsx'],
|
|
|
|
['@babel/plugin-syntax-top-level-await'],
|
|
|
|
],
|
|
|
|
cacheDirectory: true,
|
|
|
|
cacheCompression: true,*/
|
2021-05-03 19:00:50 +02:00
|
|
|
},
|
|
|
|
},
|
2021-08-04 01:12:53 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s?css$/,
|
|
|
|
use: [{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
},
|
2021-05-03 19:00:50 +02:00
|
|
|
{
|
2021-08-04 01:12:53 +02:00
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
2021-08-09 18:42:50 +02:00
|
|
|
sourceMap: true,
|
2021-08-04 01:12:53 +02:00
|
|
|
},
|
2021-01-20 16:31:34 +01:00
|
|
|
},
|
2021-05-03 19:00:50 +02:00
|
|
|
{
|
2021-08-04 01:12:53 +02:00
|
|
|
loader: 'resolve-url-loader',
|
2021-01-20 16:31:34 +01:00
|
|
|
},
|
2021-05-03 19:00:50 +02:00
|
|
|
{
|
2021-08-04 01:12:53 +02:00
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
2021-08-09 18:42:50 +02:00
|
|
|
sourceMap: true,
|
2021-08-04 01:12:53 +02:00
|
|
|
},
|
|
|
|
}, ],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
|
2021-08-08 20:43:40 +02:00
|
|
|
type: "asset/resource",
|
2021-08-04 01:12:53 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/,
|
2021-08-08 20:43:40 +02:00
|
|
|
type: "asset/resource",
|
|
|
|
}, {
|
|
|
|
test: /\.(png|webp|jpg|jpeg|gif|svg)$/,
|
|
|
|
type: "asset/resource",
|
2021-08-04 01:12:53 +02:00
|
|
|
}, ],
|
2021-01-20 16:31:34 +01:00
|
|
|
},
|
2021-05-03 19:00:50 +02:00
|
|
|
plugins: plugins,
|
|
|
|
|
2021-08-11 19:17:10 +02:00
|
|
|
mode: 'development',
|
|
|
|
devtool: 'inline-source-map',
|
2021-05-03 19:00:50 +02:00
|
|
|
devServer: {
|
|
|
|
host: IP,
|
|
|
|
port: PORT,
|
|
|
|
historyApiFallback: false,
|
|
|
|
static: path.resolve(__dirname, conf['APPDIR'], conf['SRC']),
|
|
|
|
https: conf['HTTPS'],
|
2021-08-11 19:17:10 +02:00
|
|
|
hot: false, //true,
|
2021-05-03 19:00:50 +02:00
|
|
|
//injectClient: conf['injectClient'],
|
|
|
|
|
|
|
|
headers: {
|
|
|
|
'Access-Control-Allow-Origin': '*',
|
|
|
|
'Referrer-Policy': 'unsafe-url',
|
|
|
|
'service-worker-allowed': '/',
|
|
|
|
},
|
2021-01-20 16:31:34 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = config;
|