mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-25 16:05:27 +03:00
Merge pull request #2980 from urbit/lf/webpack-qol
interface: improve webpack dev config
This commit is contained in:
commit
26d4f33968
@ -1,5 +1,6 @@
|
||||
module.exports = {
|
||||
URBIT_PIERS: [
|
||||
"/Users/user/ships/zod/home",
|
||||
]
|
||||
],
|
||||
herb: false
|
||||
};
|
||||
|
@ -2,6 +2,41 @@ const path = require('path');
|
||||
// const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
// const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const urbitrc = require('./urbitrc');
|
||||
const fs = require('fs');
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
|
||||
function copyFile(src,dest) {
|
||||
return new Promise((res,rej) =>
|
||||
fs.copyFile(src,dest, err => err ? rej(err) : res()));
|
||||
}
|
||||
|
||||
class UrbitShipPlugin {
|
||||
constructor(urbitrc) {
|
||||
this.piers = urbitrc.URBIT_PIERS;
|
||||
this.herb = urbitrc.herb || false;
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.hooks.afterCompile.tapPromise(
|
||||
'UrbitShipPlugin',
|
||||
async (compilation) => {
|
||||
const src = path.resolve(compiler.options.output.path, 'index.js');
|
||||
return Promise.all(this.piers.map(pier => {
|
||||
const dst = path.resolve(pier, 'app/landscape/js/index.js');
|
||||
copyFile(src, dst).then(() => {
|
||||
if(!this.herb) {
|
||||
return;
|
||||
}
|
||||
pier = pier.split('/');
|
||||
const desk = pier.pop();
|
||||
return exec(`herb -p hood -d '+hood/commit %${desk}' ${pier.join('/')}`);
|
||||
});
|
||||
}));
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
@ -49,16 +84,18 @@ module.exports = {
|
||||
// historyApiFallback: true
|
||||
// },
|
||||
plugins: [
|
||||
new UrbitShipPlugin(urbitrc)
|
||||
// new CleanWebpackPlugin(),
|
||||
// new HtmlWebpackPlugin({
|
||||
// title: 'Hot Module Replacement',
|
||||
// template: './public/index.html',
|
||||
// }),
|
||||
],
|
||||
watch: true,
|
||||
output: {
|
||||
filename: 'index.js',
|
||||
chunkFilename: 'index.js',
|
||||
path: path.resolve(urbitrc.URBIT_PIERS[0] + '/app/landscape/', 'js'),
|
||||
path: path.resolve(__dirname, '../dist'),
|
||||
publicPath: '/'
|
||||
},
|
||||
optimization: {
|
||||
|
Loading…
Reference in New Issue
Block a user