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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webpack): Add webpack-dev-server, add yarn.lock #22

Merged
merged 5 commits into from Mar 17, 2017

Conversation

ChinW
Copy link
Contributor

@ChinW ChinW commented Mar 12, 2017

Hi contributors,

I am really appreciated for your work, it does help me have a quick start to TS! I am wondering whether it would be helpful by adding webpack-dev-server into this starter? Something likes npm run dev, which allows us to start a server, so that we can have features like hot-reload, and debugging ts with WebStorm/VSC, etc.

I hope this could be helpful. and it's my opinion of course. Up to you 馃憤

--- New Package Script ---
npm run dev: Run a server at localhost:8081 for quick development

Copy link
Owner

@alexjoverm alexjoverm left a comment

Choose a reason for hiding this comment

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

Hi @ChinW, thank you very much for this PR! Absolutely is a good feature for the starter! Great job!

I've requested some small changes. About the 2 spaces thing, that's something that could be improved adding an .editorconfig. I've opened #24 for that. In the meanwhile, just make sure you use 2-space indentation everywhere.

Thanks!

const dev = !(env && env === 'production');
const entry = dev ? [
// 'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:8081',
Copy link
Owner

Choose a reason for hiding this comment

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

Please use 2 space indentation according to tslint

]
],
devServer: {
hot: true,
Copy link
Owner

Choose a reason for hiding this comment

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

same here

template: join(__dirname, 'src/template/common.html'),
hash: true,
chunks: ['common', 'index']
}),
new TypedocWebpackPlugin(
Copy link
Owner

Choose a reason for hiding this comment

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

For dev we don't need to run Typedoc anymoore. Could you make it that it only runs on production?

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
Copy link
Owner

Choose a reason for hiding this comment

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

2 spaces indent here as well

@ChinW
Copy link
Contributor Author

ChinW commented Mar 15, 2017

@alexjoverm Thanks for your comments 馃憤 I have modified them, please check ;)

Copy link
Owner

@alexjoverm alexjoverm left a comment

Choose a reason for hiding this comment

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

@ChinW sorry I have a small additional change that I haven't realized before.

Additionally, I have a concern. Since this boilerplate is for writing TS libraries, it is not related to HTML and that shouldn't be part of the source code or the dist (now when running npm run build an index.html is generated there). So, my suggestion:

  • In webpack.config make the HTMLWebpackPlugin only execute on dev
  • Move template/common.html out of src folder. What about in the root (/template/common.html)?

What do you think about this? Any other suggestions?

Thanks a lot for your time, and sorry for the extra work, but I'd like to keep the quality standard of the project :)

/**
* Update this variable if you change your library name
*/
const libraryName = '--libraryname--'
const plugins = [
new CheckerPlugin(),
new webpack.HotModuleReplacementPlugin(),
Copy link
Owner

Choose a reason for hiding this comment

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

Also, we don't need the Hot Module replacement when building for production. Can you make it only for development?

@ChinW
Copy link
Contributor Author

ChinW commented Mar 15, 2017

@alexjoverm You are most welcome! I have learned a lot from this project 馃憤 Please check the update.

And for the HTMLWebpackPlugin, I suggest to execute it both on dev and prod, because if users develop the library while checking it by browsers in development environment, they may also want to check the library's effect in production environment. Thus a HTML file should always be generated.

I will update this if you still think it is not necessary in this case ;) And any problems pls let me known, I am very willing to do some help, updating is a kind of advancing to me 馃嵒

Copy link
Owner

@alexjoverm alexjoverm left a comment

Choose a reason for hiding this comment

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

@ChinW Glad to see your high motivation :)

Supposedly the generated file should work as development, but I see your point and probably some people would like to do some manual testing with the bundles.

In that case, I suggest to create a .npmignore file with dist/index.html in it, since we don't want that index.html to be distributed when the people install the library created with this starter. Check this for more info

With that and a what I wrote in the comments (the deleted src/library and the renaming to index.html) we're done for this PR

src/library.ts Outdated
@@ -1,3 +0,0 @@
export default class DummyClass {
Copy link
Owner

Choose a reason for hiding this comment

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

Apparently you removed this folder and file. Please revert that, is there on purpose, otherwise you'll see running npm t would fail.

@@ -0,0 +1,11 @@
<!doctype html>
Copy link
Owner

Choose a reason for hiding this comment

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

Can we rename this to index.html? In order to keep consistency with the dist/index.html generated file.

@ChinW
Copy link
Contributor Author

ChinW commented Mar 17, 2017

@alexjoverm Thanks for your time :D I have modified these parts, please check

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

Successfully merging this pull request may close these issues.

None yet

2 participants