-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Export react-scripts functionality #781
Comments
I checked out the webpack config files in react-scripts and found out that these configuration also depends on |
Can you provide more specific use cases please? |
Sure. We need two additional tools for building our applications:
My thought was how I can extend For this it would be nice to use react-scripts as a library to create my-react-scripts. Example
var merge = require('webpack-merge');
// This is the "original" configuration from react-scripts
var base = require('react-scripts/config/webpack.config.dev');
var MyCustomWebpackPlugin = require('my-custom-webpack-plugin');
module.exports = merge(base, {
loaders: [
{ test: /\.scss$/, loader: 'style!css!postcss!sass' },
]
plugins: [
new MyCustomWebpackPlugin()
]
}); This configuration file can be used in var start = require('react-scripts/scripts/start');
var config = require('../config/webpack.config.dev');
var paths = require('../config/paths');
start(config, paths); In my project I would install my-react-scripts and use it in my scripts. Maybe we can extract the functionality of the react-scripts scripts into a |
I think you might have better luck with an approach like this custom-react-scripts. |
Yes, the more I think about it I think it is not so useful and makes react-scripts more complicated and harder to maintain. Thank you for you time. And thank you for your great work (not only for create-react-app). |
I started thinking about how I can extend the existing react-scripts functionality. E.g. I want to add some additional webpack plugins. I saw that #419 is the good move into an extendable system. But instead of forking react-scripts I want to extends or wrap it and benefit from the existing scripts.
My idea is to wrap the execution of the script in a function and pass the config and paths from outside:
This makes it possible to load the config and execute the script directly ...
... or export the main function.
With this structure everyone can execute the script or use it like a library to provide own scripts.
I created a pull request (#776) with a few changes which make it possible to use it like a library. If someone want to checkout the code and has some hints what could be better feel free to let there a comment. :-)
The text was updated successfully, but these errors were encountered: