Skip to content

Commit

Permalink
Merge pull request #16 from royGil/master
Browse files Browse the repository at this point in the history
a simpler approach to get output content
  • Loading branch information
ardatan authored May 10, 2018
2 parents bb23b3f + 77bee70 commit 38a5557
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
16 changes: 9 additions & 7 deletions atmosphere-packages/webpack-dev-middleware/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,14 @@ if (Meteor.isServer && Meteor.isDevelopment) {
index: false,
...clientConfig.devServer
}));
clientConfig.devServer.index = clientConfig.devServer.index || './index.html';
compiler.hooks.done.tap('meteor-webpack', () => {
const clientCompiler = compiler.compilers.find(compiler => (compiler.name == 'client'));
const indexPath = path.join(clientConfig.devServer.contentBase, clientConfig.devServer.index);
if (clientCompiler.outputFileSystem.existsSync(indexPath)) {
const content = clientCompiler.outputFileSystem.readFileSync(indexPath, 'utf8');

compiler.hooks.done.tap('meteor-webpack', ({ stats }) => {
const { assets } = stats[0].compilation
const index = clientConfig.devServer.index || 'index.html'

if (index in assets) {
const content = assets[index].source()

WebAppInternals.registerBoilerplateDataCallback('meteor/ardatan:webpack', (req, data) => {
const head = HEAD_REGEX.exec(content)[1];
data.dynamicHead = data.dynamicHead || '';
Expand All @@ -267,4 +269,4 @@ if (Meteor.isServer && Meteor.isDevelopment) {

}

}
}
45 changes: 45 additions & 0 deletions examples/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
"webpack-dev-middleware": "^3.1.3",
"webpack-hot-middleware": "^2.22.1"
}
}
}

0 comments on commit 38a5557

Please sign in to comment.