Commit 31860acc authored by JC Brand's avatar JC Brand

Makefile: add recipe for setting the CDN url as the `publicPath`

parent 68e34351
...@@ -38,7 +38,6 @@ help: ...@@ -38,7 +38,6 @@ help:
@echo " build Create minified builds of converse.js and all its dependencies." @echo " build Create minified builds of converse.js and all its dependencies."
@echo " clean Remove all NPM packages." @echo " clean Remove all NPM packages."
@echo " check Run all tests." @echo " check Run all tests."
@echo " css Generate CSS from the Sass files."
@echo " dev Set up the development environment and build unminified resources. To force a fresh start, run 'make clean' first." @echo " dev Set up the development environment and build unminified resources. To force a fresh start, run 'make clean' first."
@echo " devserver Set up the development environment and start the webpack dev server." @echo " devserver Set up the development environment and start the webpack dev server."
@echo " html Make standalone HTML files of the documentation." @echo " html Make standalone HTML files of the documentation."
...@@ -131,9 +130,6 @@ devserver: stamp-npm ...@@ -131,9 +130,6 @@ devserver: stamp-npm
######################################################################## ########################################################################
## Builds ## Builds
.PHONY: css
css: sass/*.scss dist/website.css dist/website.min.css
dist/converse.js:: stamp-npm dev dist/converse.js:: stamp-npm dev
dist/converse.css:: stamp-npm dev dist/converse.css:: stamp-npm dev
...@@ -173,15 +169,19 @@ BUILDS = src/headless/dist/converse-headless.min.js ...@@ -173,15 +169,19 @@ BUILDS = src/headless/dist/converse-headless.min.js
@converse/headless: src/headless @converse/headless: src/headless
src/headless/dist/converse-headless.min.js: src webpack.common.js stamp-npm @converse/headless src/headless/dist/converse-headless.min.js: src webpack.common.js stamp-npm @converse/headless
npm run converse-headless.min.js npm run headless
.PHONY: dist .PHONY: dist
dist:: build dist:: build
.PHONY: build .PHONY: build
build:: stamp-npm css build:: stamp-npm
npm run build npm run dev && npm run build
.PHONY: cdn
cdn:: stamp-npm
npm run cdn
######################################################################## ########################################################################
## Tests ## Tests
......
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
"scripts": { "scripts": {
"serve": "webpack-dev-server --config webpack.serve.js", "serve": "webpack-dev-server --config webpack.serve.js",
"clean": "rm -rf node_modules stamp-npm dist *.zip", "clean": "rm -rf node_modules stamp-npm dist *.zip",
"converse-headless.min.js": "webpack --config webpack.headless.js", "headless": "webpack --config webpack.headless.js",
"nodeps": "webpack --config webpack.nodeps.js", "nodeps": "webpack --config webpack.nodeps.js",
"cdn": "ASSET_PATH=https://cdn.conversejs.org/dist npm run dev && ASSET_PATH=https://cdn.conversejs.org/dist npm run build",
"build": "webpack --config webpack.prod.js", "build": "webpack --config webpack.prod.js",
"dev": "webpack --config webpack.dev.js", "dev": "webpack --config webpack.dev.js",
"watch": "webpack --watch --config webpack.dev.js", "watch": "webpack --watch --config webpack.dev.js",
......
/* global module */ /* global module, process */
const merge = require("webpack-merge"); const merge = require("webpack-merge");
const prod = require("./webpack.prod.js"); const prod = require("./webpack.prod.js");
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ASSET_PATH = process.env.ASSET_PATH || '/dist/'; // eslint-disable-line no-process-env
module.exports = merge(prod, { module.exports = merge(prod, {
output: { output: {
publicPath: '/dist/', // URL base path for all assets publicPath: ASSET_PATH,
filename: 'converse.js', filename: 'converse.js',
}, },
optimization: { optimization: {
minimize: false, minimize: false,
}, },
devtool: 'source-map', devtool: 'source-map',
plugins: [new MiniCssExtractPlugin({filename: 'converse.css'})] plugins: [
new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
})
],
}); });
/* global __dirname, module */ /* global __dirname, module, process */
const common = require("./webpack.common.js"); const common = require("./webpack.common.js");
const merge = require("webpack-merge"); const merge = require("webpack-merge");
const path = require('path'); const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ASSET_PATH = process.env.ASSET_PATH || '/dist/'; // eslint-disable-line no-process-env
module.exports = merge(common, { module.exports = merge(common, {
output: { output: {
publicPath: '/dist/', // URL base path for all assets publicPath: ASSET_PATH,
filename: 'converse.min.js', filename: 'converse.min.js',
}, },
plugins: [ plugins: [
new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}) new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
})
], ],
mode: "production", mode: "production",
devtool: "source-map", 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