From aa88eb2374546ff2d83ef6afd80185acad91061e Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 27 Feb 2017 15:33:52 -0700 Subject: [PATCH] Adjusted build process --- README.md | 5 ++++- package.json | 5 +++-- routes/index.js | 3 ++- webpack.config.js | 23 ++++++++++++++++++----- yarn.lock | 6 ++++++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f47fbd2f6..64fe2739c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Talk [![CircleCI](https://circleci.com/gh/coralproject/talk.svg?style=svg)](https://circleci.com/gh/coralproject/talk) -A commenting platform from [The Coral Project](https://coralproject.net). Talk enters a closed beta in March 2017, but you can download the code for our alpha here. [Read more about Talk here.](https://coralproject.net/products/talk.html) +A commenting platform from [The Coral Project](https://coralproject.net). Talk enters a closed beta in March 2017, but you can download the code for our alpha here. [Read more about Talk here.](https://coralproject.net/products/talk.html) + +Third party licenses are available via the `/client/3rdpartylicenses.txt` +endpoint when the server is running with built assets. ## Contributing to Talk diff --git a/package.json b/package.json index 70b0e17b1..cbf3a1267 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "start": "./bin/cli serve --jobs", "dev-start": "nodemon --config .nodemon.json --exec \"./bin/cli -c .env serve --jobs\"", - "build": "NODE_ENV=production webpack -p --config webpack.config.js --bail", - "build-watch": "NODE_ENV=development webpack --config webpack.config.js --watch", + "build": "NODE_ENV=production webpack --progress -p --config webpack.config.js --bail", + "build-watch": "NODE_ENV=development webpack --progress --config webpack.config.js --watch", "lint": "eslint bin/* .", "lint-fix": "eslint bin/* . --fix", "test": "TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}", @@ -130,6 +130,7 @@ "jsdom": "^9.8.3", "json-loader": "^0.5.4", "keymaster": "^1.6.2", + "license-webpack-plugin": "^0.4.2", "material-design-lite": "^1.2.1", "mocha": "^3.1.2", "mocha-junit-reporter": "^1.12.1", diff --git a/routes/index.js b/routes/index.js index a771ff50b..b1e61659a 100644 --- a/routes/index.js +++ b/routes/index.js @@ -5,7 +5,8 @@ const router = express.Router(); router.use('/api/v1', require('./api')); router.use('/admin', require('./admin')); router.use('/embed', require('./embed')); -router.get('/embed.js', (req, res) => res.sendFile(path.join(__dirname, '../dist/coral-embed/bundle.js'))); +router.get('/embed.js', (req, res) => res.sendFile(path.join(__dirname, '../dist/embed.js'))); +router.get('/embed.js.map', (req, res) => res.sendFile(path.join(__dirname, '../dist/embed.js.map'))); if (process.env.NODE_ENV !== 'production') { router.use('/assets', require('./assets')); diff --git a/webpack.config.js b/webpack.config.js index ecd138e2b..cd00696d8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,14 +2,14 @@ const path = require('path'); const autoprefixer = require('autoprefixer'); const precss = require('precss'); const Copy = require('copy-webpack-plugin'); +const LicenseWebpackPlugin = require('license-webpack-plugin'); const webpack = require('webpack'); // Edit the build targets and embeds below. const buildTargets = [ 'coral-admin', - 'coral-docs', - 'coral-embed' + 'coral-docs' ]; const buildEmbeds = [ @@ -18,7 +18,12 @@ const buildEmbeds = [ module.exports = { devtool: 'cheap-source-map', - entry: buildTargets.reduce((entry, target) => { + entry: Object.assign({}, { + 'embed': [ + 'babel-polyfill', + path.join(__dirname, 'client/coral-embed/src/index') + ] + }, buildTargets.reduce((entry, target) => { // Add the entry for the bundle. entry[`${target}/bundle`] = [ @@ -27,7 +32,7 @@ module.exports = { ]; return entry; - }, buildEmbeds.reduce((entry, embed) => { + }, {}), buildEmbeds.reduce((entry, embed) => { // Add the entry for the bundle. entry[`embed/${embed}/bundle`] = [ @@ -39,6 +44,7 @@ module.exports = { }, {})), output: { path: path.join(__dirname, 'dist'), + publicPath: '/client/', filename: '[name].js', // NOTE: this causes all exports to override the global.Coral, so no more @@ -50,7 +56,10 @@ module.exports = { { loader: 'babel-loader', exclude: /node_modules/, - test: /\.js$/ + test: /\.js$/, + query: { + cacheDirectory: true + } }, { loader: 'json-loader', @@ -85,6 +94,10 @@ module.exports = { ] }, plugins: [ + new LicenseWebpackPlugin({ + pattern: /^(MIT|ISC|BSD.*)$/, + addUrl: true + }), new Copy([ ...buildEmbeds.map(embed => ({ from: path.join(__dirname, 'client', `coral-embed-${embed}`, 'style'), diff --git a/yarn.lock b/yarn.lock index 5413439fa..0331202ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4385,6 +4385,12 @@ libqp@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/libqp/-/libqp-1.1.0.tgz#f5e6e06ad74b794fb5b5b66988bf728ef1dedbe8" +license-webpack-plugin@^0.4.2: + version "0.4.2" + resolved "https://registry.yarnpkg.com/license-webpack-plugin/-/license-webpack-plugin-0.4.2.tgz#188df5418a72ab61cad648b9ffd9355be270242b" + dependencies: + object-assign "^4.1.0" + linkify-it@^1.2.0: version "1.2.4" resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-1.2.4.tgz#0773526c317c8fd13bd534ee1d180ff88abf881a"