According to the documentation, Importing any Grapesjs plugin and adding it via config.grapesJsConfig.plugins.push
should active/load the plugin but I am getting an error!
Silex failed to load and stuck in a "Loading" state with an error message in the console
main.js:362 Uncaught (in promise) TypeError: Failed to resolve module specifier "grapesjs-blocks-flexbox". Relative references must start with either "/", "./", or "../".
Here is what I am trying,
// my .silex-client config file
import Eleventy from './js/silex-cms/client.js'
import blocksFlexbox from 'grapesjs-blocks-flexbox';
import websiteInfoPlugin from './plugins/client/website-info.js'
//import basicBlock from './plugin/basic-block.js';
export default function(config, options) {
config.addPlugin(websiteInfoPlugin, {})
config.addPlugin(blocksFlexbox, {})
// CMS Plugin
config.addPlugin(Eleventy, {
dataSources: [],
//fetchPlugin : { duration: '1d', type: 'json', removeUrlQueryParams: true } // https://www.11ty.dev/docs/plugins/fetch/
})
config.on('silex:startup:end', () => {
const editor = config.getEditor()
editor.on('storage:end:store', async () => {
editor.runCommand('publish')
})
})
}
Also tried loading it via "CMS plugin" style
const StaticPlugin = require('@silexlabs/silex/dist/plugins/server/plugins/server/StaticPlugin').default
const node_modules = require('node_modules-path')
console.log('node_modules ->', node_modules('@silexlabs/silex-cms'))
console.log('node_modules ->', node_modules('grapesjs-blocks-flexbox'))
module.exports = async function(config, options) {
await config.addPlugin(StaticPlugin, {
routes: [
{
route: '/js/silex-cms/',
path: node_modules('@silexlabs/silex-cms') + '/@silexlabs/silex-cms/dist/',
},
{
route: '/js/grapesjs-blocks-flexbox/',
path: node_modules('grapesjs-blocks-flexbox') + '/grapesjs-blocks-flexbox/dist/'
}
],
})
}
but it couldn't find /js/grapesjs-blocks-flexbox/index.js
! when I try to import it in the client.js. What am I doing wrong here?