mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-23 17:00:24 +01:00
refactor: use build/public for webpack
This commit is contained in:
@@ -40,7 +40,6 @@
|
|||||||
"bootstrap": "3.4.1",
|
"bootstrap": "3.4.1",
|
||||||
"chalk": "4.1.2",
|
"chalk": "4.1.2",
|
||||||
"chart.js": "2.9.4",
|
"chart.js": "2.9.4",
|
||||||
"clean-webpack-plugin": "4.0.0",
|
|
||||||
"cli-graph": "3.2.2",
|
"cli-graph": "3.2.2",
|
||||||
"clipboard": "2.0.10",
|
"clipboard": "2.0.10",
|
||||||
"colors": "1.4.0",
|
"colors": "1.4.0",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ require('../app');
|
|||||||
// scripts-admin.min contains javascript files
|
// scripts-admin.min contains javascript files
|
||||||
// from plugins that add files to "acpScripts" block in plugin.json
|
// from plugins that add files to "acpScripts" block in plugin.json
|
||||||
// eslint-disable-next-line import/no-unresolved
|
// eslint-disable-next-line import/no-unresolved
|
||||||
require('../../scripts-admin.min');
|
require('../../scripts-admin');
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
let logoutTimer = 0;
|
let logoutTimer = 0;
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ require('./app');
|
|||||||
// scripts-client.min contains javascript files
|
// scripts-client.min contains javascript files
|
||||||
// from plugins that add files to "scripts" block in plugin.json
|
// from plugins that add files to "scripts" block in plugin.json
|
||||||
// eslint-disable-next-line import/no-unresolved
|
// eslint-disable-next-line import/no-unresolved
|
||||||
require('../scripts-client.min');
|
require('../scripts-client');
|
||||||
|
|||||||
@@ -128,9 +128,9 @@ async function getBundleScriptList(target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS.buildBundle = async function (target, fork) {
|
JS.buildBundle = async function (target, fork) {
|
||||||
const filename = `scripts-${target}.min.js`;
|
const filename = `scripts-${target}.js`;
|
||||||
const files = await getBundleScriptList(target);
|
const files = await getBundleScriptList(target);
|
||||||
const minify = process.env.NODE_ENV !== 'development';
|
const minify = false; // webpack will minify in prod
|
||||||
const filePath = path.join(__dirname, '../../build/public', filename);
|
const filePath = path.join(__dirname, '../../build/public', filename);
|
||||||
|
|
||||||
await minifier.js.bundle({
|
await minifier.js.bundle({
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ function addCoreRoutes(app, router, middleware, mounts) {
|
|||||||
|
|
||||||
const statics = [
|
const statics = [
|
||||||
{ route: '/assets', path: path.join(__dirname, '../../build/public') },
|
{ route: '/assets', path: path.join(__dirname, '../../build/public') },
|
||||||
{ route: '/assets', path: path.join(__dirname, '../../build/webpack') }, // todo: messy; relocate in v3
|
|
||||||
{ route: '/assets', path: path.join(__dirname, '../../public') },
|
{ route: '/assets', path: path.join(__dirname, '../../public') },
|
||||||
];
|
];
|
||||||
const staticOptions = {
|
const staticOptions = {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ const path = require('path');
|
|||||||
const url = require('url');
|
const url = require('url');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
||||||
|
|
||||||
const activePlugins = require('./build/active_plugins.json');
|
const activePlugins = require('./build/active_plugins.json');
|
||||||
|
|
||||||
let relativePath = nconf.get('relative_path');
|
let relativePath = nconf.get('relative_path');
|
||||||
@@ -19,18 +17,21 @@ if (relativePath === undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [],
|
||||||
new CleanWebpackPlugin(), // cleans dist folder
|
|
||||||
],
|
|
||||||
entry: {
|
entry: {
|
||||||
nodebb: './build/public/src/client.js',
|
nodebb: './build/public/src/client.js',
|
||||||
admin: './build/public/src/admin/admin.js',
|
admin: './build/public/src/admin/admin.js',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].min.js',
|
filename: '[name].min.js',
|
||||||
chunkFilename: '[name].[contenthash].js',
|
chunkFilename: '[name].[contenthash].min.js',
|
||||||
path: path.resolve(__dirname, 'build/webpack'),
|
path: path.resolve(__dirname, 'build/public'),
|
||||||
publicPath: `${relativePath}/assets/`,
|
publicPath: `${relativePath}/assets/`,
|
||||||
|
clean: {
|
||||||
|
keep(asset) {
|
||||||
|
return !asset.endsWith('.min.js');
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watchOptions: {
|
watchOptions: {
|
||||||
poll: 500,
|
poll: 500,
|
||||||
|
|||||||
Reference in New Issue
Block a user