Commit b3e13c5e authored by JC Brand's avatar JC Brand

Add webpack config for making a headless build

parent 41c4f9ce
......@@ -167,17 +167,14 @@ logo/conversejs-filled%.png:: logo/conversejs-filled.svg
$(INKSCAPE) -e $@ -w $* $<
$(OXIPNG) $@
BUILDS = src/headless/dist/converse-headless.js \
src/headless/dist/converse-headless.min.js
BUILDS = src/headless/dist/converse-headless.min.js
@converse/headless: src/headless
src/headless/dist/converse-headless.js: src webpack.common.js stamp-npm @converse/headless
npm run converse-headless.js
src/headless/dist/converse-headless.min.js: src webpack.common.js stamp-npm @converse/headless
npm run converse-headless.min.js
@converse/headless: src/headless
.PHONY: dist
dist:: build
......
......@@ -17,8 +17,7 @@
"scripts": {
"serve": "webpack-dev-server --config webpack.serve.js",
"clean": "rm -rf node_modules stamp-npm dist *.zip",
"converse-headless.js": "webpack --mode=development --type=headless",
"converse-headless.min.js": "npm run converse-headless.js && webpack --mode=production --type=headless",
"converse-headless.min.js": "webpack --config webpack.headless.js",
"nodeps": "webpack --config webpack.nodeps.js",
"build": "webpack --config webpack.prod.js",
"dev": "webpack --config webpack.dev.js",
......
/* global __dirname, module, process */
const HTMLWebpackPlugin = require('html-webpack-plugin');
const minimist = require('minimist');
const path = require('path');
const webpack = require('webpack');
const config = {
module.exports = {
output: {
path: path.resolve(__dirname, 'dist'), // Output path for generated bundles
publicPath: '/dist/', // URL base path for all assets
......@@ -140,26 +138,3 @@ const config = {
}
}
}
function extend (o1, o2) {
for (var i in o2) {
if (Object.prototype.hasOwnProperty.call(o2, i)) {
o1[i] = o2[i];
}
}
}
function parameterize () {
const type = minimist(process.argv.slice(2)).type;
const mode = minimist(process.argv.slice(2)).mode;
const lang = minimist(process.argv.slice(2)).lang;
if (type === 'headless') {
console.log("Making a headless build");
config.entry = "@converse/headless/headless.js";
config.output.filename = 'converse-headless.js';
}
}
parameterize();
module.exports = config;
/* global __dirname, module */
const common = require("./webpack.common.js");
const merge = require("webpack-merge");
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = merge(common, {
entry: "@converse/headless/headless.js",
output: {
path: path.resolve(__dirname, 'src/headless/dist'), // Output path for generated bundles
filename: 'converse-headless.min.js',
chunkFilename: '[name].js'
},
mode: "production",
devtool: "source-map",
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment