2018-06-07 07:04:45 +02:00
|
|
|
/*global path, __dirname, module, process */
|
2018-05-24 21:09:33 +02:00
|
|
|
'use strict'
|
2018-06-04 12:07:49 +02:00
|
|
|
const minimist = require('minimist');
|
2018-05-24 21:09:33 +02:00
|
|
|
const path = require('path');
|
2018-11-15 11:44:16 +01:00
|
|
|
const webpack = require('webpack');
|
2019-04-18 16:56:27 +02:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2018-05-24 21:09:33 +02:00
|
|
|
|
|
|
|
const config = {
|
|
|
|
entry: path.resolve(__dirname, 'src/converse.js'),
|
|
|
|
externals: [{
|
|
|
|
"window": "window"
|
|
|
|
}],
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
filename: 'converse.js'
|
|
|
|
},
|
|
|
|
devtool: 'source-map',
|
2018-11-15 11:44:16 +01:00
|
|
|
plugins: [
|
2019-04-18 16:56:27 +02:00
|
|
|
new MiniCssExtractPlugin({filename: '../css/converse.css'}),
|
2018-11-15 11:44:16 +01:00
|
|
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
|
|
|
|
],
|
2018-05-24 21:09:33 +02:00
|
|
|
module: {
|
2018-06-02 17:18:42 +02:00
|
|
|
rules: [
|
|
|
|
{
|
2018-06-06 18:31:04 +02:00
|
|
|
test: path.resolve(__dirname, "node_modules/backbone.overview/backbone.orderedlistview"),
|
2018-06-02 17:18:42 +02:00
|
|
|
use: 'imports-loader?backbone.nativeview'
|
|
|
|
},
|
|
|
|
{
|
2018-06-06 18:31:04 +02:00
|
|
|
test: path.resolve(__dirname, "node_modules/backbone.overview/backbone.overview"),
|
2018-06-02 17:18:42 +02:00
|
|
|
use: 'imports-loader?backbone.nativeview'
|
|
|
|
},
|
|
|
|
{
|
2018-06-06 18:31:04 +02:00
|
|
|
test: path.resolve(__dirname, "node_modules/backbone.vdomview/backbone.vdomview"),
|
2018-06-02 17:18:42 +02:00
|
|
|
use: 'imports-loader?backbone.nativeview'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: path.resolve(__dirname, "node_modules/xss/dist/xss"),
|
|
|
|
use: "exports-loader?filterXSS,filterCSS"
|
|
|
|
},
|
|
|
|
{
|
2019-04-18 16:56:27 +02:00
|
|
|
test: /templates\/.*\.(html|svg)$/,
|
2018-05-24 21:09:33 +02:00
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [{
|
|
|
|
loader: 'lodash-template-webpack-loader',
|
|
|
|
options: {
|
|
|
|
"escape": /\{\{\{([\s\S]+?)\}\}\}/g,
|
|
|
|
"evaluate": /\{\[([\s\S]+?)\]\}/g,
|
|
|
|
"interpolate": /\{\{([\s\S]+?)\}\}/g,
|
|
|
|
// By default, template places the values from your data in the
|
|
|
|
// local scope via the with statement. However, you can specify
|
|
|
|
// a single variable name with the variable setting. This can
|
|
|
|
// significantly improve the speed at which a template is able
|
|
|
|
// to render.
|
|
|
|
"variable": 'o',
|
|
|
|
"prependFilenameComment": __dirname
|
|
|
|
}
|
|
|
|
}]
|
2019-04-18 16:56:27 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /webfonts\/.*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[path][name].[ext]',
|
|
|
|
outputPath: '../'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}, {
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
MiniCssExtractPlugin.loader, {
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
includePaths: [
|
|
|
|
path.resolve(__dirname, 'node_modules/')
|
|
|
|
],
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
}]
|
2018-05-24 21:09:33 +02:00
|
|
|
}, {
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /(node_modules|spec|mockup)/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
["@babel/preset-env", {
|
|
|
|
"targets": {
|
|
|
|
"browsers": [">1%", "not ie 11", "not op_mini all"]
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2019-01-25 07:28:28 +01:00
|
|
|
}, {
|
|
|
|
test: /bootstrap\.native/,
|
|
|
|
use: {
|
|
|
|
loader: 'bootstrap.native-loader',
|
|
|
|
options: {
|
2019-04-18 14:56:35 +02:00
|
|
|
bs_version: 4,
|
2019-01-25 07:28:28 +01:00
|
|
|
ignore: ['carousel', 'scrollspy']
|
|
|
|
}
|
|
|
|
}
|
2018-05-24 21:09:33 +02:00
|
|
|
}],
|
|
|
|
},
|
|
|
|
resolve: {
|
2018-06-06 11:04:23 +02:00
|
|
|
extensions: ['.js'],
|
2018-05-24 21:09:33 +02:00
|
|
|
modules: [
|
|
|
|
'node_modules',
|
2018-06-06 11:04:23 +02:00
|
|
|
path.resolve(__dirname, "src")
|
2018-05-24 21:09:33 +02:00
|
|
|
],
|
|
|
|
alias: {
|
|
|
|
"IPv6": path.resolve(__dirname, "node_modules/urijs/src/IPv6"),
|
|
|
|
"SecondLevelDomains": path.resolve(__dirname, "node_modules/urijs/src/SecondLevelDomains"),
|
2018-09-25 13:19:26 +02:00
|
|
|
"formdata-polyfill": path.resolve(__dirname, "node_modules/formdata-polyfill/FormData"),
|
2018-05-24 21:09:33 +02:00
|
|
|
"jquery": path.resolve(__dirname, "src/jquery-stub"),
|
|
|
|
"punycode": path.resolve(__dirname, "node_modules/urijs/src/punycode"),
|
|
|
|
"snabbdom": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom"),
|
|
|
|
"snabbdom-attributes": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-attributes"),
|
|
|
|
"snabbdom-class": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-class"),
|
|
|
|
"snabbdom-dataset": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-dataset"),
|
|
|
|
"snabbdom-eventlisteners": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-eventlisteners"),
|
|
|
|
"snabbdom-props": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-props"),
|
|
|
|
"snabbdom-style": path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-style"),
|
|
|
|
"tovnode": path.resolve(__dirname, "node_modules/snabbdom/dist/tovnode"),
|
|
|
|
"underscore": path.resolve(__dirname, "src/underscore-shim"),
|
2018-06-06 11:04:23 +02:00
|
|
|
"xss": path.resolve(__dirname, "node_modules/xss/dist/xss")
|
2018-05-24 21:09:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-04 12:07:49 +02:00
|
|
|
function extend (o1, o2) {
|
2018-06-07 07:04:45 +02:00
|
|
|
for (var i in o2) {
|
|
|
|
if (Object.prototype.hasOwnProperty.call(o2, i)) {
|
|
|
|
o1[i] = o2[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-04 12:07:49 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-06-07 07:04:45 +02:00
|
|
|
if (type === 'headless') {
|
|
|
|
console.log("Making a headless build");
|
|
|
|
extend(config, {
|
2018-10-23 18:25:48 +02:00
|
|
|
entry: "@converse/headless/headless.js",
|
2018-06-07 07:04:45 +02:00
|
|
|
output: {
|
2019-03-29 21:04:56 +01:00
|
|
|
path: path.resolve(__dirname, 'src/headless/dist'),
|
2018-06-07 07:04:45 +02:00
|
|
|
filename: 'converse-headless.js'
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2018-06-04 12:07:49 +02:00
|
|
|
|
2018-06-07 07:04:45 +02:00
|
|
|
if (type === 'nodeps') {
|
|
|
|
console.log("Making a build without 3rd party dependencies");
|
|
|
|
extend(config, {
|
|
|
|
entry: path.resolve(__dirname, 'src/converse.js'),
|
|
|
|
externals: [{
|
|
|
|
"backbone.browserStorage": "backbone.browserStorage",
|
|
|
|
"backbone.overview": "backbone.overview",
|
|
|
|
"es6-promise": "es6-promise",
|
|
|
|
"lodash": "lodash",
|
|
|
|
"lodash.converter": "lodash.converter",
|
|
|
|
"lodash.noconflict": "lodash.noconflict",
|
|
|
|
"moment": "moment",
|
|
|
|
"strophe": "strophe",
|
|
|
|
"strophe.ping": "strophe.ping",
|
|
|
|
"strophe.rsm": "strophe.rsm",
|
|
|
|
"window": "window"
|
|
|
|
}],
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
filename: 'converse-no-dependencies.js'
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2018-06-04 12:07:49 +02:00
|
|
|
|
2019-04-18 16:56:27 +02:00
|
|
|
if (type === 'css') {
|
|
|
|
console.log("Building only CSS");
|
|
|
|
config.entry = path.resolve(__dirname, 'sass/converse.scss');
|
2019-04-24 14:25:51 +02:00
|
|
|
config.output = {};
|
2019-04-18 16:56:27 +02:00
|
|
|
}
|
|
|
|
|
2018-06-07 07:04:45 +02:00
|
|
|
if (mode === 'production') {
|
|
|
|
console.log("Making a production build");
|
|
|
|
const fn = config.output.filename;
|
2018-06-04 12:07:49 +02:00
|
|
|
config.output.filename = `${fn.replace(/\.js$/, '')}.min.js`;
|
2018-06-07 07:04:45 +02:00
|
|
|
}
|
2018-06-04 12:07:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
parameterize();
|
|
|
|
|
2018-05-24 21:09:33 +02:00
|
|
|
module.exports = config;
|