Skip to content

Commit

Permalink
chore: really better build config
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Oct 19, 2018
1 parent d7aa10f commit cbd8580
Show file tree
Hide file tree
Showing 7 changed files with 1,218 additions and 62 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "undefined",
"name": "junipero",
"version": "0.0.1",
"description": "Poool internal components library",
"main": "dist/undefined.min.js",
"repository": "https://github.com/p3ol/undefined.git",
"main": "dist/junipero.js",
"repository": "https://github.com/p3ol/junipero.git",
"author": "Ugo Stephant <ugo@poool.fr>",
"license": "MIT",
"private": true,
Expand Down Expand Up @@ -43,6 +43,7 @@
"uglifyjs-webpack-plugin": "^2.0.1",
"url-loader": "^1.1.2",
"webpack": "^4.20.2",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9",
"webpack-merge": "^4.1.4"
Expand All @@ -52,6 +53,6 @@
},
"scripts": {
"serve": "./node_modules/.bin/webpack-dev-server --config ./webpack.dev.js --hot --inline --open",
"build": "./node_modules/.bin/webpack --config webpack.prod.js"
"build": "./node_modules/.bin/webpack --config webpack.release.js"
}
}
10 changes: 3 additions & 7 deletions src/components/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,10 @@ class Slider extends React.Component {
}

getValue(value) {
const { min, max, step } = this.props;

return parseFloat((
Math.max(
this.props.min,
Math.min(
this.props.max,
Math.round(value / this.props.step) * this.props.step
)
)
Math.max(min, Math.min(max, Math.round(value / step) * step))
).toFixed(this.state.precision));
}

Expand Down
20 changes: 9 additions & 11 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,17 @@ const autoprefixer = require('autoprefixer');
module.exports = {
entry: {
'junipero': './src/index.js',
'examples': './examples/index.js',
},
target: 'web',
optimization: {
minimize: false,
},
module: {
rules: [{
test: /\.js/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
query: {
presets: [
['@babel/preset-env', { 'modules': false }],
'@babel/preset-react',
],
plugins: [
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-object-rest-spread',
],
},
}],
}, {
test: /\.styl$/,
Expand All @@ -49,9 +41,15 @@ module.exports = {
}],
},
node: false,
externals: {
react: 'React',
'prop-types': 'PropTypes',
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
library: 'junipero',
libraryTarget: 'umd',
sourceMapFilename: '[name].js.map',
},
};
3 changes: 3 additions & 0 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const common = require('./webpack.common');

module.exports = merge(common, {
entry: {
'examples': './examples/index.js',
},
devtool: 'inline-source-map',
mode: 'development',
devServer: {
Expand Down
13 changes: 0 additions & 13 deletions webpack.prod.js

This file was deleted.

17 changes: 17 additions & 0 deletions webpack.release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const merge = require('webpack-merge');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
// .BundleAnalyzerPlugin;

const common = require('./webpack.common');

module.exports = merge(common, {
mode: 'production',
optimization: {
minimize: true,
},
plugins: [
//new BundleAnalyzerPlugin(),
],
parallelism: 4,
devtool: 'source-map',
});
Loading

0 comments on commit cbd8580

Please sign in to comment.