Use files instead of data uri. Added option to define assetsHost

This commit is contained in:
SleepWalker 2016-09-27 08:02:19 +03:00
parent fcc5d024cc
commit 14e84d4172
5 changed files with 10 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
node_modules
dist/*
!dist/app.js
!dist/assets
.idea
vendor

View File

@ -1,7 +1,7 @@
This package allows rendering of React components into plain HTML to use it in emails. Each directory in `emails` dir corresponds to separate email template. Each email component will receive payload, passed from command line:
```
node cli --type=<email_dir_name> --payload=<json_encoded_in_base64>
node cli --type=<email_dir_name> --payload=<json_encoded_in_base64> [--assetsHost=<scheme://host:port>] [--locale=be]
```
Try `php example.php` for demo.

View File

@ -50,7 +50,6 @@
"image-size-loader": "^0.7.0",
"json-loader": "^0.5.4",
"scripts": "file:scripts",
"url-loader": "^0.5.7",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0",
"webpack-utils": "file:webpack-utils"

View File

@ -22,6 +22,12 @@ if (process.env.NODE_ENV !== 'production') {
module.exports = {
default(props) {
if (props.assetsHost) {
__webpack_public_path__ = props.assetsHost.replace(/\/*$/, '/'); // eslint-disable-line
Reflect.deleteProperty(props, 'assetsHost');
}
return ReactDOMServer.renderToStaticMarkup(
<Html>
<App {...props} />

View File

@ -68,9 +68,9 @@ const webpackConfig = {
},
{
test: /\.(png|gif|jpg|svg)$/,
loader: 'url',
loader: 'file',
query: {
name: 'assets/[name].[ext]?[hash]'
name: 'assets/[name]-[folder].[ext]?[hash]'
}
},
{