2022-05-21 21:31:56 +00:00
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const AssetsWebpackPlugin = require('assets-webpack-plugin');
|
|
|
|
const merge = require('webpack-merge').merge;
|
|
|
|
const wpConfig = require('./webpack.config.json');
|
2016-09-27 19:31:46 +00:00
|
|
|
|
2019-02-05 13:11:40 +00:00
|
|
|
let env = process.env.NODE_ENV || 'development';
|
2022-05-21 21:31:56 +00:00
|
|
|
const devMode = env === 'development';
|
|
|
|
const outputPath = path.join(__dirname, wpConfig.buildDir);
|
|
|
|
const publicPath = '/' + wpConfig.buildDir + '/';
|
2016-09-24 14:32:31 +00:00
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
const baseConfig = {
|
2017-11-29 10:01:48 +00:00
|
|
|
entry: wpConfig.entry,
|
2019-02-05 13:11:40 +00:00
|
|
|
mode: devMode ? 'development' : 'production',
|
2016-10-04 15:27:49 +00:00
|
|
|
output: {
|
2017-11-29 10:01:48 +00:00
|
|
|
path: outputPath,
|
|
|
|
publicPath: publicPath
|
2016-10-04 15:27:49 +00:00
|
|
|
},
|
|
|
|
module: {
|
2017-04-24 08:06:50 +00:00
|
|
|
rules: [
|
2022-11-17 22:47:33 +00:00
|
|
|
/*{
|
2022-11-17 22:31:48 +00:00
|
|
|
test: /\.m?js$/,
|
|
|
|
exclude: /(node_modules|bower_components)/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: ['@babel/preset-env']
|
|
|
|
}
|
|
|
|
}
|
2022-11-17 22:47:33 +00:00
|
|
|
},*/ {
|
2022-05-21 21:31:56 +00:00
|
|
|
test: /\.css$/,
|
|
|
|
use: ['style-loader', 'css-loader'],
|
|
|
|
}, {
|
|
|
|
test: /\.yml$/,
|
|
|
|
use: ['json-loader', 'yaml-loader']
|
|
|
|
}, {
|
|
|
|
test: /\.xml$/,
|
|
|
|
use: 'raw-loader'
|
|
|
|
}, {
|
|
|
|
test: /\.ttf$/,
|
|
|
|
type: 'asset/resource'
|
|
|
|
}, {
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2016-09-26 09:28:47 +00:00
|
|
|
]
|
2016-10-04 15:27:49 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
2017-04-24 08:06:50 +00:00
|
|
|
modules: [
|
|
|
|
__dirname +'/js',
|
|
|
|
__dirname,
|
2022-11-16 01:44:39 +00:00
|
|
|
__dirname +'/forms',
|
2017-04-24 08:06:50 +00:00
|
|
|
'node_modules',
|
|
|
|
'/usr/lib/node_modules'
|
|
|
|
]
|
2016-10-04 15:27:49 +00:00
|
|
|
},
|
2017-11-29 10:01:48 +00:00
|
|
|
node: {
|
|
|
|
__dirname: true
|
|
|
|
},
|
2016-09-26 09:28:47 +00:00
|
|
|
plugins: [
|
2019-02-05 13:11:40 +00:00
|
|
|
new AssetsWebpackPlugin({
|
|
|
|
path: outputPath
|
|
|
|
}),
|
2017-12-18 13:35:16 +00:00
|
|
|
new webpack.DefinePlugin({
|
2017-11-29 10:01:48 +00:00
|
|
|
_DEV_MODE: devMode,
|
|
|
|
_DEV_SERVER_PORT: wpConfig.devServerPort,
|
2022-05-05 13:56:17 +00:00
|
|
|
_PUBLIC_PATH: JSON.stringify(publicPath)
|
2017-11-29 10:01:48 +00:00
|
|
|
})
|
2016-10-11 14:45:10 +00:00
|
|
|
],
|
2022-05-05 13:56:17 +00:00
|
|
|
optimization: {
|
|
|
|
runtimeChunk: true,
|
|
|
|
splitChunks: {
|
|
|
|
chunks: 'all',
|
|
|
|
}
|
|
|
|
},
|
2017-11-29 10:01:48 +00:00
|
|
|
watchOptions: {
|
|
|
|
ignored: /node_modules/
|
|
|
|
}
|
2016-09-24 14:32:31 +00:00
|
|
|
};
|
2016-09-27 19:31:46 +00:00
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
const prodConfig = {
|
2017-11-29 10:01:48 +00:00
|
|
|
output: {
|
|
|
|
filename: '[name].[chunkhash].js',
|
|
|
|
chunkFilename: 'chunk.[id].[chunkhash].js'
|
|
|
|
},
|
2022-05-21 21:31:56 +00:00
|
|
|
optimization: {
|
2022-07-27 07:37:53 +00:00
|
|
|
moduleIds: 'deterministic'
|
2022-05-21 21:31:56 +00:00
|
|
|
},
|
2017-11-29 10:01:48 +00:00
|
|
|
devtool: 'source-map'
|
|
|
|
};
|
2016-11-07 22:26:28 +00:00
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
const devConfig = {
|
2017-11-29 10:01:48 +00:00
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: 'chunk.[id].js'
|
|
|
|
},
|
2022-05-21 21:31:56 +00:00
|
|
|
optimization: {
|
|
|
|
moduleIds: 'named'
|
|
|
|
},
|
2017-11-29 10:01:48 +00:00
|
|
|
devServer: {
|
|
|
|
host: '0.0.0.0',
|
2022-05-21 21:31:56 +00:00
|
|
|
static: __dirname,
|
2017-11-29 10:01:48 +00:00
|
|
|
port: wpConfig.devServerPort,
|
2022-05-05 13:56:17 +00:00
|
|
|
headers: {'Access-Control-Allow-Origin': '*'},
|
2022-05-21 21:31:56 +00:00
|
|
|
//stats: { chunks: false },
|
2022-05-05 13:56:17 +00:00
|
|
|
proxy: {
|
|
|
|
'/api': 'http://localhost:3000',
|
2022-05-09 13:52:29 +00:00
|
|
|
'/': {
|
|
|
|
target: 'http://localhost/projects/hedera-web',
|
|
|
|
bypass: (req) => req.path !== '/' ? req.path : null
|
|
|
|
}
|
2022-05-05 13:56:17 +00:00
|
|
|
}
|
2017-11-29 10:01:48 +00:00
|
|
|
},
|
|
|
|
devtool: 'eval'
|
|
|
|
};
|
2016-11-07 22:26:28 +00:00
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
const mrgConfig = devMode ? devConfig : prodConfig;
|
2017-12-18 13:35:16 +00:00
|
|
|
module.exports = merge(baseConfig, mrgConfig);
|