Comments (7)
It sounds like you've been able to find a process that works for you.
I'd also note that we're now supporting https://www.npmjs.com/package/create-contentful-app instead of this repo. It uses create-react-app, and should be more straightforward if you need to customise the build process.
I'd also mention suggest that if you're managing a lot of apps or extensions with shared code, you might benefit from using lerna which offers some tools for managing mono-repos.
Cheers!
from create-contentful-extension.
@asbjornh What was the solution, approach or strategy that you took? Soon to have the same situation and trying to have an informed decision
from create-contentful-extension.
@diegoaguilar No solution really π Weβve just kept duplicating code except for a couple of utility functions that donβt use node_modules
or need transpilation.
from create-contentful-extension.
@diegoaguilar I had another look at it today and it's actually not that hard to get around using Webpack.
For deployment, you'd just build with Webpack, and then do the following (contentful-cli
is required for this):
contentful extension update --force
One thing to be mindful of when building manually with webpack instead of using contentful-extension-scripts
is that the plugin can only consist of a single .html
file, so all assets (js, css etc) need to be inlined. inline-source-webpack-plugin can be used for that.
For local development, you can use webpack-dev-server
and then run the below command once the plugin is available on localhost
:
contentful extension update --src http://localhost:8080 --force
This would make the Contentful UI load the extension from localhost
just as when running contentful-extension-scripts start
.
When doing this you'll probably not want to inline your assets, since they'll be cached in the HTML which is not ideal for development. If you're using inline-source-webpack-plugin
a way of doing this is to have two HTML templates (one for development and one for production), where the production one inlines assets and the development one does not.
As for importing files from "outside" of the project folder, I don't remember exactly how to do that with Webpack but I've done it in the past so I'm fairly confident that it's still possible.
from create-contentful-extension.
Thanks for sharing this! So you're saying that if i use the contentful-cli
way for building instead of using create-contentful-extension which abstracts and wraps too much, then I'll be able to set it up with Webpack.
Correct?
from create-contentful-extension.
Well, sort of. contentful-cli
doesn't provide a way of building stuff, but it lets you upload extensions either from a url or a file. contentful-extension-scripts start
basically builds your code with Parcel and then calls into contentful-cli
here.
Here's the docs for the relevant part of contentful-cli
.
In short, if you use contentful-cli
instead of contentful-extension-scripts
you control the build system yourself.
After learning more about the Contentful tooling ecosystem I'm not really sure that this is a shortcoming of contentful-extension-scripts
tbh. It would be good to mention in the documentation how to use other build systems than Parcel though.
from create-contentful-extension.
I created a small plugin for Webpack that makes development and deployment of extensions a little easier when using Webpack: update-contentful-extension-webpack-plugin
from create-contentful-extension.
Related Issues (20)
- Upgrade dependency htmlnano to v1.0.0 to fix transitive security vulnerability HOT 1
- Building extensions does not support tsconfig `extends` property HOT 1
- Enable autoprefixer HOT 1
- zlib usage HOT 1
- Cannot find module on start HOT 2
- Added ability to pass installation parameters
- Npm audit got high vulnerabilities. HOT 2
- On Hot Reload, `getValue()` returns initial entry values instead of current values HOT 2
- Npm install high vulnerabilities.
- @contentful\contentful-extension-scripts Missing from node_modules on Windows 10 HOT 5
- Neither Javascript or Typescript sidebar project are working HOT 4
- Choose Between Class or Functional Component HOT 1
- React Dev Tools HOT 1
- Issue with UI extension creation HOT 1
- Support deployment to subfolders
- Unhandled Promise Rejection on run build
- Detect compare mode for contentful app HOT 1
- Jest test configuration generated is ignored by scripts/test.js
- Version Mismatch of with @contentful/field-editor-reference causing TypeScript errors HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-contentful-extension.