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:
fast_finish: true
include:
- node_js: 7 # Version used to deploy to npm registry
env: BUILD_ENV=production
cache:
directories:
- ~/.npm
before_script:
- NODE_ENV=$BUILD_ENV npm run build
notifications:
email:
on_success: never
@ -23,6 +29,7 @@ deploy:
api_key:
secure: I9iN31GWI+Mz0xPw81N7qh1M6uidB+3BmiPUXt8QigX45zwp9EhvfZ0U/AIdUyQwzK2RK1zLRQSt+2/1jyeVi+U+AAsRRmaAUx8iqKaQPAkPnQtElolgRP04WSgo7fvNejfM7zS939bQNKG3RlSm04yPgu+ke2igf799p2bpFe2LtyoEeIiUfrUkBiMSpMguN9XF8a7jqCyIouTKjXHR24RmzJ9r7ZoMV27yQauS7XlD81bontzNRZxTytDKdJpZ+sxGIT9mbbtM4LUFX8MeNe3p/bjWavEhrO0ZIpkbOfS/L/w1375YDoNPXxCs288lnGUH+NbGNAEfn+BTz8cmUp7jI7QWR/kNACPeopdAX4OdZxT8wfQcfQZrfCuSpKciOMC7vGgPpQqjQ61t1RKcKs9VUnwC0SwWjyo8LlzkFKnP1ks0eDGYsSoPLdpC9+76UmePkQdxMhscO8TOgkOCcsTMLiyt6ABGOGKu2iE5SsjUYtPiSiRzSBAQENoO560+xBSVTKwqvvhzUAIt4AuAQSgsFjAylDdyzKoObHX12hBdALrqSOOSVwwIQ5/jTgNAsilURHo7KPD407PhRnLOsvumL0qg4sr9S1hjuUKnNla5dg9GY8FVjJ+b2t0A2vgfG1pR1e3vrJRXrpkfRorhmjvKAk2o5you5pQ1Itty7rM=
on:
node: '4'
node: 7
condition: "$BUILD_ENV = production"
tags: true
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
cd lounge
npm install
NODE_ENV=production npm run build
npm start
```
A word of caution:
- 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`.
⚠️ 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.
## Development setup

View File

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

View File

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

View File

@ -18,6 +18,11 @@ var authFunction = localAuth;
module.exports = function() {
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()
.use(allRequests)
.use(index)

View File

@ -3,10 +3,14 @@
const webpack = require("webpack");
const path = require("path");
module.exports = {
// ********************
// Common configuration
// ********************
let config = {
entry: {
app: path.resolve(__dirname, "client/js/lounge.js"),
vendor: [
"js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
"js/bundle.vendor.js": [
"handlebars/runtime",
"jquery",
"jquery-ui/ui/widgets/sortable",
@ -17,8 +21,8 @@ module.exports = {
},
devtool: "source-map",
output: {
path: path.resolve(__dirname, "client/js"),
filename: "bundle.js",
path: path.resolve(__dirname, "client"),
filename: "[name]",
publicPath: "/"
},
module: {
@ -53,14 +57,22 @@ module.exports = {
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin(
"vendor", // chunkName
"bundle.vendor.js" // filename
),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js")
]
};
// *********************************
// 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: {
warnings: false
}
}));
}
module.exports = config;