Closed WhackoJacko closed 9 years ago
Hi,
You can define a url_to_source
attribute on the the component which will override all the django-webpack integration.
class MyComponent(ReactComponent):
url_to_source = os.path.join(STATIC_URL, 'path/to/file.js')
Assuming that you're happy to rely on your pre-existing webpack setup, avoiding django-webpack is probably the easiest way to preserve your config.
Hmm, I think that supporting an external config file is a reasonable use case. Out of curiosity, what's the command you run to bundle the asset(s)? Does webpack walk up the tree to find a conf file, or do you specify it?
Cheers, Mark
Edit:
Refactored the source_url
attribute to url_to_source
.
You should now be able to specify a path_to_source
attribute, which will enable rendering.
class MyComponent(ReactComponent):
path_to_source = os.path.join(PROJECT_ROOT, 'path/to/file.js')
MyComponent().render_to_string()
I've edited the previous comment to reflect a name change, source_url
is now url_to_source
.
You can also override the get_path_to_source
and get_url_to_source
methods if you want to define things at runtime.
Thanks for soon reply, Mark, will test url_to_source. As for webpack config file, I use default config file name 'webpack.config.js' as mentioned in official docs.
Hello, Mark! Thanks for useful app. I have two questions: 1) JS components in my app are placed outside of django directory(and then packed with webpack to django_app/staticfiles/js/bundle.js), so it's not possible to find them using django's staticfiles finder. In addition I don`t want to make this components available via staticfiles finder. How can I configure 'django-react' to work with such layout? 2) I have webpack.conf.js with lots of options defined. Is there any way to use this config file instead of 'django-webpack' default?