Marketing Site Contentful CMS UI Extensions
https://github.com/contentful/create-contentful-extension
https://www.contentful.com/developers/docs/extensibility/ui-extensions/managing-a-ui-extension/
https://www.contentful.com/developers/docs/extensibility/ui-extensions/sdk-reference/
https://contentful.github.io/contentful-management.js/contentful-management/5.11.3/
https://www.contentful.com/developers/docs/references/content-delivery-api/
// in extensions directory root, creates new extension
npx @contentful/create-contentful-extension my-extension
// Add extra packages needed for self-hosted builds
yarn add webpack webpack-cli babel-core babel-loader @babel/preset-env @babel/preset-react style-loader css-loader [email protected] html-webpack-plugin sass-loader node-sass mini-css-extract-plugin --dev
Create a webpack.config.js
file at the root
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
var path = require('path');
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: __dirname + '/build'
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
inlineSource: '.(js|css)$'
}),
new HtmlWebpackInlineSourcePlugin()
],
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/env',
{
targets: {
browsers: ['Chrome >=59']
},
modules: false,
loose: true
}
],
'@babel/react'
]
}
}
}
]
}
};
// Configures the current space / environment for the extension and commands
yarn run configure
// Deploy command if filsize is <= 512KB
yarn run deploy
// If filesize is > 512KB, add new commands in package.json
"build:prod": "webpack --config webpack.config.js",
"deploy:prod": "yarn run build:prod && contentful extension update --force --src=https://justworks-contentful-extension.herokuapp.com?url=https://raw.githubusercontent.com/justworkshr/justworks_contentful_ui_extensions/master/<NAME OF EXTENSION DIR>/build/index.html",
// then to deploy run:
yarn run build:prod
// (push to master on github first!)
yarn run deploy:prod
See this link for full list of deployment flags and options. https://www.contentful.com/developers/docs/tutorials/cli/extension-management/
You may need to deploy separate spaces and with installation parameters if your extension uses those.
- cd
- run
yarn install && yarn login && yarn configure
and select "the SANDBOX" environment - run
yarn start
to setup the extension for dev in contentful's sandbox. - run
yarn build:prod
, push to github master, thenyarn deploy:prod
to push changes live tomaster
andsandbox
contentful environments.
- If an extension is live and currently in use, please do all developonent in the Sandbox environment.
- To switch the space / environment, run
yarn run configure
and select sandbox - When development is complete, push the changes to the master branch on github and the "master` contentful environment will automatically use the new code.
- Each extension which uses Jest and the "@shared" import alias requires 2 babel files -- a
.babelrc
(for the contentful dev scripts) and ababel.config.js
file (for jest). Please keep them synced for the time being until overrides to the contentful devs scripts can be made.