Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boilerplate for Rails with Webpacker? #23

Open
kickbk opened this issue Sep 2, 2019 · 0 comments
Open

Boilerplate for Rails with Webpacker? #23

kickbk opened this issue Sep 2, 2019 · 0 comments

Comments

@kickbk
Copy link

kickbk commented Sep 2, 2019

I am facing an issue that I need to compile the component before it is sent to registerComponent.

So say I have an entry file that imports the custom component and registers like so:

import { registerDependencies } from 'mjml-validator'
import { registerComponent } from 'mjml-core'

import MjBasicComponent from './components/MjBasicComponent.js';
registerComponent(MjBasicComponent);

registerDependencies({
	'mj-column': ['mj-basic-component'],
	'mj-basic-component': [],
});

Since import MjBasicComponent from './components/MjBasicComponent.js'; will retrieve the
MjBasicComponent.js uncompiled, it will fail to register and then I get errors like:

createComponent.js:260 Uncaught TypeError: c.isRawElement is not a function
    at createComponent.js:260

BTW, my development webpacker.config.js is as follows:

const environment = require('./environment')
const path = require('path');
var env = environment.toWebpackConfig();
const merge = require('webpack-merge');

module.exports = merge({
	module: {
		rules: [
			{
				test: /\.m?js$/,
				exclude: /(node_modules|bower_components)/,
				loader: 'babel-loader',
				options: {
					presets: ['@babel/preset-env'],
				},
			},
		]
	},
	resolve: {
		alias: {
			'fs': path.resolve('node_modules/grapesjs-mjml/mocks/fs'),
			'uglify-js': path.resolve('node_modules/grapesjs-mjml/mocks/uglify-js'),
		}
	},
	target: 'web',
	externals: {
		'grapesjs': 'grapesjs',
		'jquery': 'jQuery',
	},
}, env);

Any ideas on how to compile MjBasicComponent before it is sent to the registerComponent function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant