Commit 07b69cd3 authored by 邓晓峰's avatar 邓晓峰

fix: webpack bug

parent c2c70e4a
const rm = require('rimraf');
const path = require('path');
const webpack = require('webpack');
const chalk = require('chalk');
const ora = require('ora')
const pkg = require('../../package.json');
const webpackConfig = require('./webpack.prod.babel')
const argv = require('../../server/argv');
const spinner = ora('building for production...')
spinner.start()
rm(argv.releasepath ? path.resolve(argv.releasepath, pkg.name.toLocaleLowerCase()): `./${pkg.name.toLocaleLowerCase()}`, err => {
if (err) throw err
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
color: true,
progress: true,
modules: false,
children: false,
chunks: true,
chunkModules: true
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})
"use strict";
var rm = require('rimraf');
var path = require('path');
var webpack = require('webpack');
var chalk = require('chalk');
var ora = require('ora');
var pkg = require('../../package.json');
var webpackConfig = require('./webpack.prod.babel');
var argv = require('../../server/argv');
var spinner = ora('building for production...');
spinner.start();
rm(argv.releasepath ? path.resolve(argv.releasepath, pkg.name.toLocaleLowerCase()) : "./".concat(pkg.name.toLocaleLowerCase()), function (err) {
if (err) throw err;
webpack(webpackConfig, function (err, stats) {
spinner.stop();
if (err) throw err;
process.stdout.write(stats.toString({
colors: true,
color: true,
progress: true,
modules: false,
children: false,
chunks: true,
chunkModules: true
}) + '\n\n');
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'));
process.exit(1);
}
console.log(chalk.cyan(' Build complete.\n'));
console.log(chalk.yellow(' Tip: built files are meant to be served over an HTTP server.\n' + ' Opening index.html over file:// won\'t work.\n'));
});
});
\ No newline at end of file
This diff is collapsed.
......@@ -23,7 +23,7 @@
"build:clean": "rimraf ./build",
"start": "cross-env NODE_ENV=development node server --port=$port",
"start:tunnel": "cross-env NODE_ENV=development ENABLE_TUNNEL=true node server",
"start:production": "npm run test && npm run build && npm run start:prod",
"start:production": "npm run test && npm run build && npm run start:prod",
"start:prod": "cross-env NODE_ENV=production node server",
"release": "np --no-cleanup --yolo --no-publish",
"cm": "git-cz",
......@@ -203,6 +203,7 @@
"node-plop": "0.18.0",
"null-loader": "0.1.1",
"offline-plugin": "5.0.6",
"ora": "^5.1.0",
"path-to-regexp": "^2.4.0",
"plop": "2.3.0",
"postcss": "7.0.32",
......@@ -229,6 +230,7 @@
"rimraf": "2.6.3",
"shelljs": "0.8.3",
"slash2": "^2.0.0",
"spinner": "^0.3.4",
"style-loader": "^1.2.1",
"stylelint": "10.0.1",
"stylelint-config-recommended": "2.2.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment