0
1
Fork 0
hedera-web-mindshore/webpack.config.js

93 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-12-18 13:35:16 +00:00
var path = require('path');
var webpack = require('webpack');
var AssetsWebpackPlugin = require('assets-webpack-plugin');
var merge = require('webpack-merge');
var 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';
var devMode = env === 'development';
2017-12-18 13:35:16 +00:00
var outputPath = path.join(__dirname, wpConfig.buildDir);
var publicPath = wpConfig.buildDir +'/';
2016-09-24 14:32:31 +00:00
var baseConfig = {
entry: wpConfig.entry,
2019-02-05 13:11:40 +00:00
mode: devMode ? 'development' : 'production',
2016-10-04 15:27:49 +00:00
output: {
path: outputPath,
publicPath: publicPath
2016-10-04 15:27:49 +00:00
},
module: {
rules: [
{ test: /\.css$/, loader: 'style-loader!css-loader' },
2018-02-05 12:58:17 +00:00
{ test: /\.yml$/, loader: 'json-loader!yaml-loader' },
{ test: /\.xml$/, loader: 'raw-loader' },
{ test: /\.ttf$/, loader: 'file-loader' }
2016-09-26 09:28:47 +00:00
]
2016-10-04 15:27:49 +00:00
},
resolve: {
modules: [
__dirname +'/js',
__dirname,
'node_modules',
'/usr/lib/node_modules'
]
2016-10-04 15:27:49 +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({
_DEV_MODE: devMode,
_DEV_SERVER_PORT: wpConfig.devServerPort,
2022-05-05 13:56:17 +00:00
_PUBLIC_PATH: JSON.stringify(publicPath)
})
2016-10-11 14:45:10 +00:00
],
2022-05-05 13:56:17 +00:00
optimization: {
runtimeChunk: true,
splitChunks: {
chunks: 'all',
}
},
watchOptions: {
ignored: /node_modules/
}
2016-09-24 14:32:31 +00:00
};
2016-09-27 19:31:46 +00:00
var prodConfig = {
output: {
filename: '[name].[chunkhash].js',
chunkFilename: 'chunk.[id].[chunkhash].js'
},
plugins: [
new webpack.HashedModuleIdsPlugin()
],
devtool: 'source-map'
};
var devConfig = {
output: {
filename: '[name].js',
chunkFilename: 'chunk.[id].js'
},
plugins: [
2017-12-18 13:35:16 +00:00
new webpack.NamedModulesPlugin()
],
devServer: {
host: '0.0.0.0',
port: wpConfig.devServerPort,
2022-05-05 13:56:17 +00:00
headers: {'Access-Control-Allow-Origin': '*'},
stats: { chunks: false },
proxy: {
'/api': 'http://localhost:3000',
'/': 'http://localhost/projects/hedera-web'
}
},
devtool: 'eval'
};
var mrgConfig = devMode ? devConfig : prodConfig;
2017-12-18 13:35:16 +00:00
module.exports = merge(baseConfig, mrgConfig);