Merge pull request #858 from thelounge/xpaw/tweak-webpack

Do not uglify builds when running start-dev
This commit is contained in:
Alistair McKinlay 2017-01-23 10:42:38 +00:00 committed by GitHub
commit 91ae814ead
6 changed files with 45 additions and 22 deletions

View File

@ -6,11 +6,17 @@ node_js:
matrix: matrix:
fast_finish: true fast_finish: true
include:
- node_js: 7 # Version used to deploy to npm registry
env: BUILD_ENV=production
cache: cache:
directories: directories:
- ~/.npm - ~/.npm
before_script:
- NODE_ENV=$BUILD_ENV npm run build
notifications: notifications:
email: email:
on_success: never on_success: never
@ -23,6 +29,7 @@ deploy:
api_key: api_key:
secure: I9iN31GWI+Mz0xPw81N7qh1M6uidB+3BmiPUXt8QigX45zwp9EhvfZ0U/AIdUyQwzK2RK1zLRQSt+2/1jyeVi+U+AAsRRmaAUx8iqKaQPAkPnQtElolgRP04WSgo7fvNejfM7zS939bQNKG3RlSm04yPgu+ke2igf799p2bpFe2LtyoEeIiUfrUkBiMSpMguN9XF8a7jqCyIouTKjXHR24RmzJ9r7ZoMV27yQauS7XlD81bontzNRZxTytDKdJpZ+sxGIT9mbbtM4LUFX8MeNe3p/bjWavEhrO0ZIpkbOfS/L/w1375YDoNPXxCs288lnGUH+NbGNAEfn+BTz8cmUp7jI7QWR/kNACPeopdAX4OdZxT8wfQcfQZrfCuSpKciOMC7vGgPpQqjQ61t1RKcKs9VUnwC0SwWjyo8LlzkFKnP1ks0eDGYsSoPLdpC9+76UmePkQdxMhscO8TOgkOCcsTMLiyt6ABGOGKu2iE5SsjUYtPiSiRzSBAQENoO560+xBSVTKwqvvhzUAIt4AuAQSgsFjAylDdyzKoObHX12hBdALrqSOOSVwwIQ5/jTgNAsilURHo7KPD407PhRnLOsvumL0qg4sr9S1hjuUKnNla5dg9GY8FVjJ+b2t0A2vgfG1pR1e3vrJRXrpkfRorhmjvKAk2o5you5pQ1Itty7rM= secure: I9iN31GWI+Mz0xPw81N7qh1M6uidB+3BmiPUXt8QigX45zwp9EhvfZ0U/AIdUyQwzK2RK1zLRQSt+2/1jyeVi+U+AAsRRmaAUx8iqKaQPAkPnQtElolgRP04WSgo7fvNejfM7zS939bQNKG3RlSm04yPgu+ke2igf799p2bpFe2LtyoEeIiUfrUkBiMSpMguN9XF8a7jqCyIouTKjXHR24RmzJ9r7ZoMV27yQauS7XlD81bontzNRZxTytDKdJpZ+sxGIT9mbbtM4LUFX8MeNe3p/bjWavEhrO0ZIpkbOfS/L/w1375YDoNPXxCs288lnGUH+NbGNAEfn+BTz8cmUp7jI7QWR/kNACPeopdAX4OdZxT8wfQcfQZrfCuSpKciOMC7vGgPpQqjQ61t1RKcKs9VUnwC0SwWjyo8LlzkFKnP1ks0eDGYsSoPLdpC9+76UmePkQdxMhscO8TOgkOCcsTMLiyt6ABGOGKu2iE5SsjUYtPiSiRzSBAQENoO560+xBSVTKwqvvhzUAIt4AuAQSgsFjAylDdyzKoObHX12hBdALrqSOOSVwwIQ5/jTgNAsilURHo7KPD407PhRnLOsvumL0qg4sr9S1hjuUKnNla5dg9GY8FVjJ+b2t0A2vgfG1pR1e3vrJRXrpkfRorhmjvKAk2o5you5pQ1Itty7rM=
on: on:
node: '4' node: 7
condition: "$BUILD_ENV = production"
tags: true tags: true
repo: thelounge/lounge repo: thelounge/lounge

View File

@ -50,14 +50,12 @@ The following commands install the development version of The Lounge:
git clone https://github.com/thelounge/lounge.git git clone https://github.com/thelounge/lounge.git
cd lounge cd lounge
npm install npm install
NODE_ENV=production npm run build
npm start npm start
``` ```
A word of caution: ⚠️ While it is the most recent codebase, this is not production-ready! Run at
your own risk. It is also not recommended to run this as root.
- While it is the most recent codebase, this is not production-ready!
- It is not recommended to run this as root. However, if you decide to do so,
you will have to run `npm run build`.
## Development setup ## Development setup

View File

@ -13,6 +13,7 @@ environment:
install: install:
- ps: Install-Product node $env:nodejs_version - ps: Install-Product node $env:nodejs_version
- appveyor-retry npm install - appveyor-retry npm install
- npm run build
- npm install mocha-appveyor-reporter - npm install mocha-appveyor-reporter
- echo --reporter mocha-appveyor-reporter >> test/mocha.opts - echo --reporter mocha-appveyor-reporter >> test/mocha.opts

View File

@ -18,13 +18,13 @@
"build": "npm-run-all build:*", "build": "npm-run-all build:*",
"build:font-awesome": "node scripts/build-fontawesome.js", "build:font-awesome": "node scripts/build-fontawesome.js",
"build:webpack": "webpack", "build:webpack": "webpack",
"watch": "webpack -w", "watch": "webpack --watch",
"test": "npm-run-all -c test:* lint", "test": "npm-run-all -c test:* lint",
"test:mocha": "mocha", "test:mocha": "mocha",
"lint": "npm-run-all -c lint:*", "lint": "npm-run-all -c lint:*",
"lint:js": "eslint .", "lint:js": "eslint .",
"lint:css": "stylelint \"**/*.css\"", "lint:css": "stylelint \"**/*.css\"",
"prepublish": "npm run build" "prepublishOnly": "NODE_ENV=production npm run build"
}, },
"keywords": [ "keywords": [
"lounge", "lounge",

View File

@ -18,6 +18,11 @@ var authFunction = localAuth;
module.exports = function() { module.exports = function() {
manager = new ClientManager(); manager = new ClientManager();
if (!fs.existsSync("client/js/bundle.js")) {
log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production npm run build")} to resolve this.`);
process.exit();
}
var app = express() var app = express()
.use(allRequests) .use(allRequests)
.use(index) .use(index)

View File

@ -3,10 +3,14 @@
const webpack = require("webpack"); const webpack = require("webpack");
const path = require("path"); const path = require("path");
module.exports = { // ********************
// Common configuration
// ********************
let config = {
entry: { entry: {
app: path.resolve(__dirname, "client/js/lounge.js"), "js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
vendor: [ "js/bundle.vendor.js": [
"handlebars/runtime", "handlebars/runtime",
"jquery", "jquery",
"jquery-ui/ui/widgets/sortable", "jquery-ui/ui/widgets/sortable",
@ -17,8 +21,8 @@ module.exports = {
}, },
devtool: "source-map", devtool: "source-map",
output: { output: {
path: path.resolve(__dirname, "client/js"), path: path.resolve(__dirname, "client"),
filename: "bundle.js", filename: "[name]",
publicPath: "/" publicPath: "/"
}, },
module: { module: {
@ -53,14 +57,22 @@ module.exports = {
] ]
}, },
plugins: [ plugins: [
new webpack.optimize.CommonsChunkPlugin( new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js")
"vendor", // chunkName ]
"bundle.vendor.js" // filename };
),
new webpack.optimize.UglifyJsPlugin({ // *********************************
// Production-specific configuration
// *********************************
if (process.env.NODE_ENV === "production") {
config.plugins.push(new webpack.optimize.DedupePlugin());
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: { compress: {
warnings: false warnings: false
} }
}), }));
] }
};
module.exports = config;