Files
NodeBB/webpack.common.js

58 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-02-14 21:35:33 -05:00
'use strict';
const path = require('path');
const url = require('url');
const nconf = require('nconf');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const activePlugins = require('./build/active_plugins.json');
let relativePath = nconf.get('relative_path');
if (relativePath === undefined) {
nconf.file({
file: path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json'),
});
const urlObject = url.parse(nconf.get('url'));
relativePath = urlObject.pathname !== '/' ? urlObject.pathname.replace(/\/+$/, '') : '';
}
module.exports = {
plugins: [
new CleanWebpackPlugin(), // cleans dist folder
],
entry: {
nodebb: './build/public/src/app.js',
admin: './build/public/src/admin/admin.js',
2022-02-14 21:35:33 -05:00
},
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, 'build/webpack'),
publicPath: `${relativePath}/assets/`,
2022-02-14 21:35:33 -05:00
},
watchOptions: {
poll: 500,
aggregateTimeout: 250,
2022-02-14 21:35:33 -05:00
},
resolve: {
symlinks: false,
modules: [
'build/public/src/modules',
'build/public/src',
2022-02-14 21:35:33 -05:00
'node_modules',
...activePlugins.map(p => `node_modules/${p}/node_modules`),
],
alias: {
assets: path.resolve(__dirname, 'build/public'),
forum: path.resolve(__dirname, 'build/public/src/client'),
admin: path.resolve(__dirname, 'build/public/src/admin'),
2022-02-14 21:35:33 -05:00
vendor: path.resolve(__dirname, 'public/vendor'),
benchpress: path.resolve(__dirname, 'node_modules/benchpressjs'),
2022-02-17 16:35:42 -05:00
Chart: path.resolve(__dirname, 'node_modules/chart.js'),
Sortable: path.resolve(__dirname, 'node_modules/sortablejs'),
'jquery-ui/widgets': path.resolve(__dirname, 'node_modules/jquery-ui/ui/widgets'),
2022-02-14 21:35:33 -05:00
},
},
};