Skip to content

Instantly share code, notes, and snippets.

@MattMcNam
Created March 22, 2017 19:00
Show Gist options
  • Save MattMcNam/3cdef529afe95649a575ecde23bfea6e to your computer and use it in GitHub Desktop.
Save MattMcNam/3cdef529afe95649a575ecde23bfea6e to your computer and use it in GitHub Desktop.
webpack + nodecg
const express = require('express');
const app = express();
const {NODE_ENV} = process.env;
module.exports = function(nodecg) {
if (NODE_ENV !== 'production') {
const webpack = require('webpack');
const webpackConfig = require('../webpack.dev.config');
const devMiddleware = require('webpack-dev-middleware');
const compiler = devMiddleware(webpack(webpackConfig), {
publicPath: webpackConfig.output.publicPath,
stats: {colors: true},
log: nodecg.log
});
app.use(compiler);
}
nodecg.mount(app);
};
...
<script src="graphic.min.js"></script>
...
...
"scripts": {
"build": "webpack --progress -p"
}
...
const path = require('path');
const webpack = require('webpack');
module.exports = {
context: path.join(__dirname, 'graphics'), // This...
devtool: "inline-sourcemap",
entry: './js/index.js',
output: {
path: path.join(__dirname, 'graphics'), // this...
publicPath: '/graphics/tagg-stack/', // and this are the important lines
filename: 'graphic.min.js'
},
plugins: [
new webpack.NoEmitOnErrorsPlugin()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment