Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const webpack = require('webpack'); // webpack engine
- const webpackConfig = require('./webpack.config.js'); // webpack configuration object
- const WebpackDevServer = require('webpack-dev-server'); // webpack development server
- // Set the event based on the npm script that is running (start, build, test, etc.)
- const npmEvent = process.env.npm_lifecycle_event;
- // decide which method to run based on the event
- switch (npmEvent) {
- ...
- }
- // method to create and run development server
- function startDevelopmentServer() {
- const compiler = webpack(webpackConfig);
- const server = new WebpackDevServer(compiler, {
- hot: true,
- stats: 'minimal'
- });
- server.listen('8080', 'localhost', () => console.log(`WebpackDevServer running on port 8080`));
- }
- // method to build static webapp
- function buildDistFolder() {
- const compiler = webpack(webpackConfig);
- compiler.run((err, stats) => {
- if (err || stats.hasErrors()) {
- console.info(err);
- }
- console.info('dist build finished');
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement