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

Add option to build React webpart #12

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ demo/node_modules
demo/resources/web/demo/gen
demo/resources/views/helloWorld.html
demo/resources/views/helloWorld.view.xml
demo/resources/views/helloWorld.webpart.xml
demo/resources/views/helloWorldDev.html
demo/resources/views/helloWorldDev.view.xml
demo/resources/views/helloWorldDev.webpart.xml
demo/resources/views/todoList.html
demo/resources/views/todoList.view.xml
demo/resources/views/todoListDev.html
Expand Down
4 changes: 4 additions & 0 deletions demo/webpack/app.webpart.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<webpart xmlns="http://labkey.org/data/xml/webpart"
title="<%= htmlWebpackPlugin.options.title %>">
<view name="<%= htmlWebpackPlugin.options.name %>"/>
</webpart>
6 changes: 4 additions & 2 deletions demo/webpack/entryPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ module.exports = {
name: 'helloWorld',
title: 'Hello World Page',
permission: 'read',
path: './src/client/HelloWorldPage'
path: './src/client/HelloWorldPage',
webpart: true
},{
name: 'todoList',
title: 'To-Do List Page',
permission: 'insert',
path: './src/client/ToDoListPage'
path: './src/client/ToDoListPage',
webpart: false
}]
};
20 changes: 20 additions & 0 deletions demo/webpack/prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ for (let i = 0; i < entryPoints.apps.length; i++) {
template: 'webpack/app.template.html'
})
]);

if (entryPoint.webpart) {
plugins = plugins.concat([
new HtmlWebpackPlugin({
inject: false,
name: entryPoint.name,
title: entryPoint.title,
filename: '../../../views/' + entryPoint.name + '.webpart.xml',
template: 'webpack/app.webpart.template.xml'
}),
new HtmlWebpackPlugin({
inject: false,
mode: 'dev',
name: entryPoint.name + "Dev",
title: entryPoint.title + " Dev",
filename: '../../../views/' + entryPoint.name + 'Dev.webpart.xml',
template: 'webpack/app.webpart.template.xml'
Comment on lines +59 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@helenmiller16 Were you able to get the hot module reloading, dev mode, working for the webpart using this approach. I just pulled down the PR and tried it but that Dev.webpart.xml just shows as blank. I would assume that the better option might be to continue to use the view itself for HMR and then just produce the webpart.xml for the non-dev mode version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cnathe thanks for taking a look! Hmm, that's odd that it's not building, worked fine for me -- that's how I've been developing the React webpart I'm working on. As you mentioned, you wouldn't be able to load it on the page if the non-dev webpart is already there.

})
])
}
}

plugins.push(new MiniCssExtractPlugin());
Expand Down