diff --git a/ChangeLog.md b/ChangeLog.md index fab3be1e..cbed8ff4 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,12 @@ +#2.2.19 + * Power management panel now displays modules in descending order of power usage by default + * Shot speed can no longer be modified directly. Its value is derived from the range modifier for Long Range and Focused modifications + * Ensure that jump range chart updates when fuel slider is changed + * Add 'Engine profile' and 'FSD profile' charts. These show how your maximum speed/jump range will alter as you alter the mass of your build + * Use coriolis-data 2.2.19: + * Remove shot speed modification - it is directly tied to range + * Fix incorrect minimal mass for 3C bi-weave shield generator + #2.2.18 * Change methodology for calculating explorer role; can result in lighter builds * Tidy up layout for module selection and lay everything out in a consistent best-to-worst for both class and grade diff --git a/package.json b/package.json index 75a1be19..8797a507 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coriolis_shipyard", - "version": "2.2.18", + "version": "2.2.19", "repository": { "type": "git", "url": "https://github.com/EDCD/coriolis" @@ -19,7 +19,7 @@ "test": "jest", "prod-serve": "nginx -p $(pwd) -c nginx.conf", "prod-stop": "kill -QUIT $(cat nginx.pid)", - "build": "npm run clean && NODE_ENV=production webpack -d -p --config webpack.config.prod.js", + "build": "npm run clean && NODE_ENV=production webpack -p --config webpack.config.prod.js", "rsync": "rsync -ae \"ssh -i $CORIOLIS_PEM\" --delete build/ $CORIOLIS_USER@$CORIOLIS_HOST:~/wwws", "deploy": "npm run lint && npm test && npm run build && npm run rsync" }, @@ -54,7 +54,7 @@ ] }, "devDependencies": { - "appcache-webpack-plugin": "^1.2.1", + "appcache-webpack-plugin": "^1.3.0", "babel-core": "*", "babel-eslint": "*", "babel-jest": "*", @@ -68,9 +68,9 @@ "eslint-plugin-react": "^4.0.0", "expose-loader": "^0.7.1", "express": "^4.13.3", - "extract-text-webpack-plugin": "^0.9.1", + "extract-text-webpack-plugin": "2.0.0", "file-loader": "^0.8.4", - "html-webpack-plugin": "^1.7.0", + "html-webpack-plugin": "^2.28.0", "jest-cli": "^16.0.1", "jsen": "^0.6.0", "json-loader": "^0.5.3", @@ -83,8 +83,8 @@ "rollup-plugin-node-resolve": "2", "style-loader": "^0.13.0", "url-loader": "^0.5.6", - "webpack": "^1.9.6", - "webpack-dev-server": "^1.14.0" + "webpack": "^2.2.1", + "webpack-dev-server": "^2.4.1" }, "dependencies": { "babel-polyfill": "*", diff --git a/src/app/components/DamageDealt.jsx b/src/app/components/DamageDealt.jsx index 2e048c97..bb4bd484 100644 --- a/src/app/components/DamageDealt.jsx +++ b/src/app/components/DamageDealt.jsx @@ -494,7 +494,7 @@ export default class DamageDealt extends TranslatedComponent { const sortOrder = this._sortOrder; const onCollapseExpand = this._onCollapseExpand; - const code = ship.getHardpointsString() + '.' + ship.getModificationsString() + '.' + against.properties.name; + const code = ship.getHardpointsString() + '.' + ship.getModificationsString() + '.' + ship.getPowerEnabledString() + '.' + against.properties.name; return ( diff --git a/src/app/components/EngineProfile.jsx b/src/app/components/EngineProfile.jsx new file mode 100644 index 00000000..6e4af044 --- /dev/null +++ b/src/app/components/EngineProfile.jsx @@ -0,0 +1,150 @@ +import React from 'react'; +import TranslatedComponent from './TranslatedComponent'; +import { Ships } from 'coriolis-data/dist'; +import ShipSelector from './ShipSelector'; +import { nameComparator } from '../utils/SlotFunctions'; +import LineChart from '../components/LineChart'; +import Slider from '../components/Slider'; +import * as ModuleUtils from '../shipyard/ModuleUtils'; +import Module from '../shipyard/Module'; +import * as Calc from '../shipyard/Calculations'; + +/** + * Engine profile for a given ship + */ +export default class EngineProfile extends TranslatedComponent { + static PropTypes = { + ship: React.PropTypes.object.isRequired, + chartWidth: React.PropTypes.number.isRequired, + code: React.PropTypes.string.isRequired + }; + + /** + * Constructor + * @param {Object} props React Component properties + * @param {Object} context React Component context + */ + constructor(props, context) { + super(props); + + const ship = this.props.ship; + + this.state = { + cargo: ship.cargoCapacity, + calcMaxSpeedFunc: this._calcMaxSpeed.bind(this, ship) + }; + } + + /** + * Update the state if our ship changes + * @param {Object} nextProps Incoming/Next properties + * @param {Object} nextContext Incoming/Next conext + * @return {boolean} Returns true if the component should be rerendered + */ + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.code != this.props.code) { + this.setState({ cargo: nextProps.ship.cargoCapacity, calcMaxSpeedFunc: this._calcMaxSpeed.bind(this, nextProps.ship) }); + } + return true; + } + + /** + * Calculate the maximum speed for this ship across its applicable mass + * @param {Object} ship The ship + * @param {Object} mass The mass at which to calculate the top speed + * @return {number} The maximum speed + */ + _calcMaxSpeed(ship, mass) { + // Obtain the thrusters for this ship + const thrusters = ship.standard[1].m; + + // Obtain the top speed + return Calc.speed(mass, ship.speed, thrusters, ship.engpip)[4]; + } + + /** + * Update cargo level + * @param {number} cargoLevel Cargo level 0 - 1 + */ + _cargoChange(cargoLevel) { + let ship = this.props.ship; + let cargo = Math.round(ship.cargoCapacity * cargoLevel); + this.setState({ + cargo + }); + } + + /** + * Render engine profile + * @return {React.Component} contents + */ + render() { + const { language, onWindowResize, sizeRatio, tooltip, termtip } = this.context; + const { formats, translate, units } = language; + const { ship } = this.props; + const { cargo } = this.state; + + // Calculate bounds for our line chart + const thrusters = ship.standard[1].m; + const minMass = thrusters.getMinMass(); + const maxMass = thrusters.getMaxMass(); + const minSpeed = Calc.speed(maxMass, ship.speed, thrusters, ship.engpip)[4]; + const maxSpeed = Calc.speed(minMass, ship.speed, thrusters, ship.engpip)[4]; + let mass = ship.unladenMass + ship.fuelCapacity + cargo; + let mark; + if (mass < minMass) { + mark = minMass; + } else if (mass > maxMass) { + mark = maxMass; + } else { + mark = mass; + } + + const cargoPercent = cargo / ship.cargoCapacity; + + const code = ship.toString() + '.' + ship.getModificationsString() + '.' + ship.getPowerEnabledString(); + + // This graph has a precipitous fall-off so we use lots of points to make it look a little smoother + return ( + +

{translate('engine profile')}

+ + {ship.cargoCapacity ? + +

{translate('cargo carried')}: {formats.int(cargo)}{units.T}

+ + + + + + +
+ +
+
: '' } +
+ ); + } +} diff --git a/src/app/components/FSDProfile.jsx b/src/app/components/FSDProfile.jsx new file mode 100644 index 00000000..7633a34a --- /dev/null +++ b/src/app/components/FSDProfile.jsx @@ -0,0 +1,151 @@ +import React from 'react'; +import TranslatedComponent from './TranslatedComponent'; +import { Ships } from 'coriolis-data/dist'; +import ShipSelector from './ShipSelector'; +import { nameComparator } from '../utils/SlotFunctions'; +import LineChart from '../components/LineChart'; +import Slider from '../components/Slider'; +import * as ModuleUtils from '../shipyard/ModuleUtils'; +import Module from '../shipyard/Module'; +import * as Calc from '../shipyard/Calculations'; + +/** + * FSD profile for a given ship + */ +export default class FSDProfile extends TranslatedComponent { + static PropTypes = { + ship: React.PropTypes.object.isRequired, + chartWidth: React.PropTypes.number.isRequired, + code: React.PropTypes.string.isRequired + }; + + /** + * Constructor + * @param {Object} props React Component properties + * @param {Object} context React Component context + */ + constructor(props, context) { + super(props); + + const ship = this.props.ship; + + this.state = { + cargo: ship.cargoCapacity, + calcMaxRangeFunc: this._calcMaxRange.bind(this, ship) + }; + } + + /** + * Update the state if our ship changes + * @param {Object} nextProps Incoming/Next properties + * @param {Object} nextContext Incoming/Next conext + * @return {boolean} Returns true if the component should be rerendered + */ + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.code != this.props.code) { + this.setState({ cargo: nextProps.ship.cargoCapacity, calcMaxRangeFunc: this._calcMaxRange.bind(this, nextProps.ship) }); + } + return true; + } + + /** + * Calculate the maximum range for this ship across its applicable mass + * @param {Object} ship The ship + * @param {Object} mass The mass at which to calculate the maximum range + * @return {number} The maximum range + */ + _calcMaxRange(ship, mass) { + // Obtain the FSD for this ship + const fsd = ship.standard[2].m; + + // Obtain the maximum range + return Calc.jumpRange(mass, fsd, fsd.getMaxFuelPerJump()); + } + + /** + * Update cargo level + * @param {number} cargoLevel Cargo level 0 - 1 + */ + _cargoChange(cargoLevel) { + let ship = this.props.ship; + let cargo = Math.round(ship.cargoCapacity * cargoLevel); + this.setState({ + cargo + }); + } + + /** + * Render engine profile + * @return {React.Component} contents + */ + render() { + const { language, onWindowResize, sizeRatio, tooltip, termtip } = this.context; + const { formats, translate, units } = language; + const { ship } = this.props; + const { cargo } = this.state; + + + // Calculate bounds for our line chart - use thruster info for X + const thrusters = ship.standard[1].m; + const fsd = ship.standard[2].m; + const minMass = thrusters.getMinMass(); + const maxMass = thrusters.getMaxMass(); + const minRange = 0; + const maxRange = Calc.jumpRange(minMass + fsd.getMaxFuelPerJump(), fsd, fsd.getMaxFuelPerJump()); + let mass = ship.unladenMass + fsd.getMaxFuelPerJump() + cargo; + let mark; + if (mass < minMass) { + mark = minMass; + } else if (mass > maxMass) { + mark = maxMass; + } else { + mark = mass; + } + + const cargoPercent = cargo / ship.cargoCapacity; + + const code = ship.name + ship.toString() + '.' + ship.getModificationsString() + '.' + ship.getPowerEnabledString(); + + return ( + +

{translate('fsd profile')}

+ + {ship.cargoCapacity ? + +

{translate('cargo carried')}: {formats.int(cargo)}{units.T}

+ + + + + + +
+ +
+
: '' } +
+ ); + } +} diff --git a/src/app/components/JumpRange.jsx b/src/app/components/JumpRange.jsx new file mode 100644 index 00000000..d197ff04 --- /dev/null +++ b/src/app/components/JumpRange.jsx @@ -0,0 +1,126 @@ +import React from 'react'; +import TranslatedComponent from './TranslatedComponent'; +import { Ships } from 'coriolis-data/dist'; +import ShipSelector from './ShipSelector'; +import { nameComparator } from '../utils/SlotFunctions'; +import LineChart from '../components/LineChart'; +import Slider from '../components/Slider'; +import * as ModuleUtils from '../shipyard/ModuleUtils'; +import Module from '../shipyard/Module'; +import * as Calc from '../shipyard/Calculations'; + +/** + * Jump range for a given ship + */ +export default class JumpRange extends TranslatedComponent { + static PropTypes = { + ship: React.PropTypes.object.isRequired, + chartWidth: React.PropTypes.number.isRequired, + code: React.PropTypes.string.isRequired + }; + + /** + * Constructor + * @param {Object} props React Component properties + * @param {Object} context React Component context + */ + constructor(props, context) { + super(props); + + const ship = this.props.ship; + + this.state = { + fuelLevel: 1, + calcJumpRangeFunc: this._calcJumpRange.bind(this, ship) + }; + } + + /** + * Update the state if our ship changes + * @param {Object} nextProps Incoming/Next properties + * @param {Object} nextContext Incoming/Next conext + * @return {boolean} Returns true if the component should be rerendered + */ + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.code != this.props.code) { + this.setState({ fuelLevel: 1, + calcJumpRangeFunc: this._calcJumpRange.bind(this, nextProps.ship) }); + } + return true; + } + + /** + * Calculate the jump range this ship at a given cargo + * @param {Object} ship The ship + * @param {Object} cargo The cargo + * @return {number} The jump range + */ + _calcJumpRange(ship, cargo) { + // Obtain the FSD for this ship + const fsd = ship.standard[2].m; + + const fuel = this.state.fuelLevel * ship.fuelCapacity; + + // Obtain the jump range + return Calc.jumpRange(ship.unladenMass + fuel + cargo, fsd, fuel); + } + + /** + * Update fuel level + * @param {number} fuelLevel Fuel level 0 - 1 + */ + _fuelChange(fuelLevel) { + this.setState({ + fuelLevel, + }); + } + + /** + * Render engine profile + * @return {React.Component} contents + */ + render() { + const { language, onWindowResize, sizeRatio, tooltip, termtip } = this.context; + const { formats, translate, units } = language; + const { ship } = this.props; + const { fuelLevel } = this.state; + + const code = ship.toString() + '.' + ship.getModificationsString() + '.' + fuelLevel; + + return ( + +

{translate('jump range')}

+ +

{translate('fuel carried')}: {formats.f2(fuelLevel * ship.fuelCapacity)}{units.T}

+ + + + + + +
+ +
+
+ ); + } +} diff --git a/src/app/components/LineChart.jsx b/src/app/components/LineChart.jsx index 484d9491..41021ff2 100644 --- a/src/app/components/LineChart.jsx +++ b/src/app/components/LineChart.jsx @@ -24,6 +24,7 @@ export default class LineChart extends TranslatedComponent { xMin: React.PropTypes.number, xMax: React.PropTypes.number.isRequired, xUnit: React.PropTypes.string.isRequired, + xMark: React.PropTypes.number, yLabel: React.PropTypes.string.isRequired, yMin: React.PropTypes.number, yMax: React.PropTypes.number.isRequired, @@ -120,7 +121,7 @@ export default class LineChart extends TranslatedComponent { this.state.xScale.range([0, innerWidth]).domain([xMin, xMax || 1]).clamp(true); this.state.xAxisScale.range([0, innerWidth]).domain([xMin, xMax]).clamp(true); - this.state.yScale.range([innerHeight, 0]).domain([yMin, yMax * 1.1]); // 10% higher than maximum value for tooltip visibility + this.state.yScale.range([innerHeight, 0]).domain([yMin, yMax + (yMax - yMin) * 0.1]); // 10% higher than maximum value for tooltip visibility this.setState({ innerWidth, outerHeight, innerHeight }); } @@ -176,7 +177,6 @@ export default class LineChart extends TranslatedComponent { seriesData = [[0, yVal], [1, yVal]]; } - const markerElems = []; const detailElems = []; const seriesLines = []; @@ -187,7 +187,9 @@ export default class LineChart extends TranslatedComponent { markerElems.push(); } - this.setState({ markerElems, detailElems, seriesLines, seriesData }); + const tipHeight = 2 + (1.2 * (seriesLines ? seriesLines.length : 0.8)); + + this.setState({ markerElems, detailElems, seriesLines, seriesData, tipHeight }); } /** @@ -227,13 +229,17 @@ export default class LineChart extends TranslatedComponent { return null; } - let { xLabel, yLabel, xUnit, yUnit, colors } = this.props; + let { xMin, xMax, xLabel, yLabel, xUnit, yUnit, xMark, colors } = this.props; let { innerWidth, outerHeight, innerHeight, tipHeight, detailElems, markerElems, seriesData, seriesLines } = this.state; let line = this.line; let lines = seriesLines.map((line, i) => ).reverse(); + const markX = xMark ? innerWidth * (xMark - xMin) / (xMax - xMin) : 0; + const xmark = xMark ? : ''; + return + {xmark} {lines} d3.select(elem).call(this.xAxis)} transform={`translate(0,${innerHeight})`}> diff --git a/src/app/components/PowerManagement.jsx b/src/app/components/PowerManagement.jsx index 84b66bee..e8a81fd0 100644 --- a/src/app/components/PowerManagement.jsx +++ b/src/app/components/PowerManagement.jsx @@ -34,8 +34,8 @@ export default class PowerManagement extends TranslatedComponent { this._sort = this._sort.bind(this); this.state = { - predicate: 'n', - desc: true, + predicate: 'pwr', + desc: false, width: 0 }; } diff --git a/src/app/i18n/en.js b/src/app/i18n/en.js index 5a96d5e4..c4dc2fe0 100644 --- a/src/app/i18n/en.js +++ b/src/app/i18n/en.js @@ -281,6 +281,12 @@ The retrofit costs provides information about the costs of changing the base bui The reload costs provides information about the costs of reloading your current build.

+

Engine Profile

+The engine profile panel provides information about the capabilities of your current thrusters. The graph shows you how the maximum speed (with 4 pips to engines) alters with the overall mass of your build. The slider can be altered to change the amount of cargo you have on-board. Your engine profile can be altered by obtaining different thrusters or engineering your existing thrusters.

+ +

FSD Profile

+The FSD profile panel provides information about the capabilities of your current frame shift drive. The graph shows you how the maximum jump range alters with the overall mass of your build. The slider can be altered to change the amount of cargo you have on-board. Your FSD profile can be altered by obtaining a different FSD or engineering your existing FSD.

+

Jump Range

The jump range panel provides information about the build' jump range. The graph shows how the build's jump range changes with the amount of cargo on-board. The slider can be altered to change the amount of fuel you have on-board.

diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx index 6819a8a7..0e50fc63 100644 --- a/src/app/pages/OutfittingPage.jsx +++ b/src/app/pages/OutfittingPage.jsx @@ -8,7 +8,7 @@ import Persist from '../stores/Persist'; import Ship from '../shipyard/Ship'; import { toDetailedBuild } from '../shipyard/Serializer'; import { outfitURL } from '../utils/UrlGenerators'; -import { FloppyDisk, Bin, Switch, Download, Reload, Fuel, LinkIcon, ShoppingIcon } from '../components/SvgIcons'; +import { FloppyDisk, Bin, Switch, Download, Reload, LinkIcon, ShoppingIcon } from '../components/SvgIcons'; import ShipSummaryTable from '../components/ShipSummaryTable'; import StandardSlotSection from '../components/StandardSlotSection'; import HardpointsSlotSection from '../components/HardpointsSlotSection'; @@ -17,18 +17,17 @@ import UtilitySlotSection from '../components/UtilitySlotSection'; import OffenceSummary from '../components/OffenceSummary'; import DefenceSummary from '../components/DefenceSummary'; import MovementSummary from '../components/MovementSummary'; +import EngineProfile from '../components/EngineProfile'; +import FSDProfile from '../components/FSDProfile'; +import JumpRange from '../components/JumpRange'; import DamageDealt from '../components/DamageDealt'; import DamageReceived from '../components/DamageReceived'; -import LineChart from '../components/LineChart'; import PowerManagement from '../components/PowerManagement'; import CostSection from '../components/CostSection'; import ModalExport from '../components/ModalExport'; import ModalPermalink from '../components/ModalPermalink'; import Slider from '../components/Slider'; -const SPEED_SERIES = ['boost', '4 Pips', '2 Pips', '0 Pips']; -const SPEED_COLORS = ['#0088d2', '#ff8c0d', '#D26D00', '#c06400']; - /** * Document Title Generator * @param {String} shipName Ship Name @@ -81,7 +80,6 @@ export default class OutfittingPage extends Page { ship.buildWith(data.defaults); // Populate with default components } - let fuelCapacity = ship.fuelCapacity; this._getTitle = getTitle.bind(this, data.properties.name); return { @@ -93,12 +91,7 @@ export default class OutfittingPage extends Page { shipId, ship, code, - savedCode, - fuelCapacity, - fuelLevel: 1, - jumpRangeChartFunc: ship.calcJumpRangeWith.bind(ship, fuelCapacity), - fastestRangeChartFunc: ship.calcFastestRangeWith.bind(ship, fuelCapacity), - speedChartFunc: ship.calcSpeedsWith.bind(ship, fuelCapacity) + savedCode }; } @@ -193,13 +186,9 @@ export default class OutfittingPage extends Page { * Trigger render on ship model change */ _shipUpdated() { - let { shipId, buildName, ship, fuelCapacity } = this.state; + let { shipId, buildName, ship } = this.state; let code = ship.toString(); - if (fuelCapacity != ship.fuelCapacity) { - this._fuelChange(this.state.fuelLevel); - } - this._updateRoute(shipId, buildName, code); this.setState({ code }); } @@ -214,23 +203,6 @@ export default class OutfittingPage extends Page { Router.replace(outfitURL(shipId, code, buildName)); } - /** - * Update current fuel level - * @param {number} fuelLevel Fuel leval 0 - 1 - */ - _fuelChange(fuelLevel) { - let ship = this.state.ship; - let fuelCapacity = ship.fuelCapacity; - let fuel = fuelCapacity * fuelLevel; - this.setState({ - fuelLevel, - fuelCapacity, - jumpRangeChartFunc: ship.calcJumpRangeWith.bind(ship, fuel), - fastestRangeChartFunc: ship.calcFastestRangeWith.bind(ship, fuel), - speedChartFunc: ship.calcSpeedsWith.bind(ship, fuel) - }); - } - /** * Update dimenions from rendered DOM */ @@ -240,7 +212,7 @@ export default class OutfittingPage extends Page { if (elem) { this.setState({ thirdChartWidth: findDOMNode(this.refs.chartThird).offsetWidth, - halfChartWidth: findDOMNode(this.refs.chartHalf).offsetWidth + halfChartWidth: findDOMNode(this.refs.chartThird).offsetWidth * 3 / 2 }); } } @@ -323,7 +295,7 @@ export default class OutfittingPage extends Page { let state = this.state, { language, termtip, tooltip, sizeRatio, onWindowResize } = this.context, { translate, units, formats } = language, - { ship, code, savedCode, buildName, newBuildName, halfChartWidth, thirdChartWidth, fuelCapacity, fuelLevel } = state, + { ship, code, savedCode, buildName, newBuildName, halfChartWidth, thirdChartWidth } = state, hide = tooltip.bind(null, null), menu = this.props.currentMenu, shipUpdated = this._shipUpdated, @@ -333,6 +305,9 @@ export default class OutfittingPage extends Page { hStr = ship.getHardpointsString() + '.' + ship.getModificationsString(), iStr = ship.getInternalString() + '.' + ship.getModificationsString(); + // Code can be blank for a default loadout. Prefix it with the ship name to ensure that changes in default ships is picked up + code = ship.name + (code || ''); + return (
@@ -366,13 +341,13 @@ export default class OutfittingPage extends Page {
- - + + -
+
@@ -382,47 +357,19 @@ export default class OutfittingPage extends Page {
- - + + -
-
+
+ +
-
-

{translate('jump range')}

- - - - - - - - - -
- - - - - {formats.f2(fuelLevel * fuelCapacity)}{units.T} {formats.pct1(fuelLevel)} -
+
+ +
+ +
+
@@ -437,56 +384,3 @@ export default class OutfittingPage extends Page { ); } } -//
-//

{translate('jump range')}

-// -//
-//
-//

{translate('speed')}

-// -//
-//
-// -// -// -// -// -// -// -// -//
-// -// -// -// -// {formats.f2(fuelLevel * fuelCapacity)}{units.T} {formats.pct1(fuelLevel)} -//
-//
diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index 92f21771..1f2dea54 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -701,6 +701,16 @@ export default class Module { * @return {string} the shot speed for this module */ getShotSpeed() { + if (this.blueprint && (this.blueprint.name === 'Focused' || this.blueprintname === 'Long Range')) { + // If the modification is focused or long range then the shot speed + // uses the range modifier + const rangemod = this.getModValue('range') / 10000; + let result = this['shotspeed']; + if (!result) { + return null; + } + return result * (1 + rangemod); + } return this._getModifiedValue('shotspeed'); } diff --git a/src/index.html b/src/index.ejs similarity index 64% rename from src/index.html rename to src/index.ejs index d6742abf..27897d2a 100644 --- a/src/index.html +++ b/src/index.ejs @@ -1,9 +1,9 @@ - + > Coriolis EDCD Edition - + @@ -24,22 +24,22 @@ - {% if (o.htmlWebpackPlugin.options.uaTracking) { %} + <% if (htmlWebpackPlugin.options.uaTracking) { %> - {% } %} + <% } %>
- - + + diff --git a/src/migrate.html b/src/migrate.html deleted file mode 100644 index 5fb06c22..00000000 --- a/src/migrate.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Coriolis: Migrate to HTTPS - - - - - - - diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 0c2f06bb..0613aa29 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -27,7 +27,7 @@ module.exports = { }, resolve: { // When requiring, you don't need to add these extensions - extensions: ['', '.js', '.jsx', '.json', '.less'] + extensions: ['.js', '.jsx', '.json', '.less'] }, output: { path: path.join(__dirname, 'build'), @@ -36,30 +36,34 @@ module.exports = { }, plugins: [ new CopyDirPlugin(path.join(__dirname, 'src/.htaccess'), ''), - new webpack.optimize.CommonsChunkPlugin('lib', 'lib.js'), + new webpack.optimize.CommonsChunkPlugin({ + name: 'lib', + filename: 'lib.js' + }), new HtmlWebpackPlugin({ inject: false, - template: path.join(__dirname, "src/index.html"), + template: path.join(__dirname, "src/index.ejs"), version: pkgJson.version, gapiKey: process.env.CORIOLIS_GAPI_KEY || '', }), - new ExtractTextPlugin('app.css', { + new ExtractTextPlugin({ + filename: 'app.css', + disable: false, allChunks: true }), new webpack.HotModuleReplacementPlugin(), - new webpack.NoErrorsPlugin() + new webpack.NoEmitOnErrorsPlugin() ], module: { - loaders: [ - { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader','css-loader') }, - { test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader','css-loader!less-loader') }, - { test: /\.(js|jsx)$/, loaders: [ 'babel' ], include: path.join(__dirname, 'src') }, - { test: /\.json$/, loader: 'json-loader' }, - { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' }, - { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' }, - { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' }, - { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' }, - { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' } + rules: [ + { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader'}) }, + { test: /\.less$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!less-loader'}) }, + { test: /\.(js|jsx)$/, loaders: [ 'babel-loader' ], include: path.join(__dirname, 'src') }, + { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' }, + { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' }, + { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/octet-stream' }, + { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader' }, + { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml' } ] } }; diff --git a/webpack.config.prod.js b/webpack.config.prod.js index 8c8a66ba..bbb4f065 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -6,12 +6,6 @@ var HtmlWebpackPlugin = require("html-webpack-plugin"); var ExtractTextPlugin = require("extract-text-webpack-plugin"); var AppCachePlugin = require('appcache-webpack-plugin'); -var node_modules_dir = path.resolve(__dirname, 'node_modules'); -var d3Path = path.resolve(__dirname, 'd3.min.js'); -var reactPath = path.resolve(node_modules_dir, 'react/dist/react.min.js'); -var reactDomPath = path.resolve(node_modules_dir, 'react-dom/dist/react-dom.min.js'); -var lzStringPath = path.resolve(node_modules_dir, 'lz-string/libs/lz-string.min.js'); - function CopyDirPlugin(source, destination) { this.source = source; this.destination = destination; @@ -26,16 +20,10 @@ CopyDirPlugin.prototype.apply = function(compiler) { module.exports = { entry: { app: ['babel-polyfill', path.resolve(__dirname, 'src/app/index')], - lib: ['babel-polyfill', 'd3', 'react', 'react-dom', 'classnames', 'fbemitter', 'lz-string'] + lib: ['d3', 'react', 'react-dom', 'classnames', 'fbemitter', 'lz-string'] }, resolve: { - extensions: ['', '.js', '.jsx', '.json', '.less'], - alias: { - 'd3': d3Path, - 'react': reactPath, - 'react-dom': reactDomPath, - 'lz-string': lzStringPath - }, + extensions: ['.js', '.jsx', '.json', '.less'] }, output: { path: path.join(__dirname, 'build'), @@ -45,12 +33,12 @@ module.exports = { }, plugins: [ new webpack.optimize.UglifyJsPlugin({ - mangle: { - except: [] - }, 'screw-ie8': true }), - new webpack.optimize.CommonsChunkPlugin('lib', 'lib.[chunkhash:6].js'), + //new webpack.optimize.CommonsChunkPlugin({ + // name: 'lib', + // filename: 'lib.[chunkhash:6].js' + //}), new HtmlWebpackPlugin({ inject: false, appCache: 'coriolis.appcache', @@ -64,17 +52,18 @@ module.exports = { removeScriptTypeAttributes: true, removeStyleLinkTypeAttributes: true }, - template: path.join(__dirname, "src/index.html"), + template: path.join(__dirname, "src/index.ejs"), uaTracking: process.env.CORIOLIS_UA_TRACKING || '', gapiKey: process.env.CORIOLIS_GAPI_KEY || '', version: pkgJson.version }), - new ExtractTextPlugin('[contenthash:6].css', { + new ExtractTextPlugin({ + filename: '[contenthash:6].css', + disable: false, allChunks: true }), new CopyDirPlugin(path.join(__dirname, 'src/schemas'), 'schemas'), new CopyDirPlugin(path.join(__dirname, 'src/images/logo/*'), ''), - new CopyDirPlugin(path.join(__dirname, 'src/migrate.html'), ''), new CopyDirPlugin(path.join(__dirname, 'src/.htaccess'), ''), new AppCachePlugin({ network: ['*'], @@ -84,22 +73,15 @@ module.exports = { }) ], module: { - noParse: [d3Path, reactPath, lzStringPath], - loaders: [ - // Expose non-parsed globally scoped libs - { test: reactPath, loader: "expose?React" }, - { test: d3Path, loader: "expose?d3" }, - { test: lzStringPath, loader: "expose?LZString" }, - - { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader','css-loader') }, - { test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader','css-loader!less-loader') }, - { test: /\.(js|jsx)$/, loaders: [ 'babel' ], include: path.join(__dirname, 'src') }, - { test: /\.json$/, loader: 'json-loader' }, - { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' }, - { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' }, - { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' }, - { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' }, - { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' } + rules: [ + { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader'}) }, + { test: /\.less$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader',use: 'css-loader!less-loader'}) }, + { test: /\.(js|jsx)$/, loaders: [ 'babel-loader' ], include: path.join(__dirname, 'src') }, + { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' }, + { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' }, + { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/octet-stream' }, + { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader' }, + { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml' } ] } };