Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Build configuration #175

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line at end of file pls!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I need to configure prettier settings!

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
node_modules
*.log
.DS_Store
.idea
build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you get rid of .idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I'll make the change.

43 changes: 43 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const webpack = require("webpack");
Copy link
Contributor

@evykassirer evykassirer Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quotes please! (I'm surprised the linter didn't catch that, maybe it doesn't check for it - will open an issue)

const path = require("path");
const BabiliPlugin = require("babili-webpack-plugin");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this isn't used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Yup. We rely on uglifyJS

const CleanWebpackPlugin = require("clean-webpack-plugin");

module.exports = {
entry: path.resolve(__dirname, "../index.js"),
output: {
path: path.resolve(__dirname, "../build"),
filename: "mathsteps.min.js",
libraryTarget: "umd",
library: "mathsteps"
},
externals: {
mathjs: "mathjs"
},
module: {
rules: [
{
test: /\.js$/,
exclude: [/node_modules/, /scripts/, /test/, /Config/],
use: ["babel-loader"]
}
]
},
plugins: [
new webpack.LoaderOptionsPlugin({ // Options for loader that will run on files
minimize: true,
debug: false,
options: {
context: __dirname
}
}),
new webpack.optimize.ModuleConcatenationPlugin(), // Webpack 3 (scope hoisting)
new webpack.optimize.UglifyJsPlugin(), // Minifier
new webpack.DefinePlugin({ // Production ready build
"process.env": {
NODE_ENV: JSON.stringify("production")
}
}),
new CleanWebpackPlugin([path.resolve(__dirname, "../build")]) // Prebuild (kinda hook)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the comments in this file to explain a bit better what things do? kinda hook confuses me

I'm not super familiar with webpack but will look some of this stuff up - but if you could go through this config and explain why you chose this config that'd be good too - thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry! I will comment the configuration and will make it easier for you also to make changes afterwards.

]
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new lineeeee (added to the linter issue)

21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,34 @@
"name": "mathsteps",
"version": "0.1.6",
"description": "Step by step math solutions",
"main": "index.js",
"main": "./build/mathsteps.min.js",
Copy link
Contributor

@evykassirer evykassirer Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if build/ is gitignored, will this not work? or will it always build before looking for main

"dependencies": {
"mathjs": "3.11.2"
},
"engines": {
"node": ">=6.0.0"
},
"files": [
"build"
],
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babili-webpack-plugin": "^0.1.2",
"clean-webpack-plugin": "^0.1.16",
"eslint": "^3.10.2",
"eslint-config-google": "^0.7.0",
"eslint-plugin-sort-requires": "^2.1.0",
"mocha": "2.4.5"
"mocha": "2.4.5",
"webpack": "^3.0.0"
},
"scripts": {
"lint": "node_modules/.bin/eslint .",
"test": "node_modules/.bin/mocha --recursive",
"setup-hooks": "ln -s ../../scripts/git-hooks/pre-commit.sh .git/hooks/pre-commit"
"build": "NODE_ENV=production ./node_modules/.bin/webpack --config ./config/webpack.config.js --display-max-modules 0",
"lint": "node_modules/.bin/eslint ./lib",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this removes linting from the test files, which I don't think we should do

"prebuild": "rm -rf ./build",
"setup-hooks": "ln -s ../../scripts/git-hooks/pre-commit.sh .git/hooks/pre-commit",
"test": "node_modules/.bin/mocha --recursive"
},
"repository": {
"type": "git",
Expand Down