Skip to content

Commit

Permalink
add minimal config to create dist for npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
berdyshev committed Aug 24, 2018
1 parent 3b32224 commit 223265f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand Down
38 changes: 38 additions & 0 deletions config/webpack.config.dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
const pkg = require('../package.json');
// const nodeExternals = require('webpack-node-externals');

module.exports = {
entry: path.resolve(__dirname, '../src/index.js'),
output: {
path: path.resolve(__dirname, '../dist'),
filename: 'index.js',
library: '',
libraryTarget: 'commonjs'
},
resolve: {
modules: ['node_modules', 'src'],
extensions: ['.js', '.jsx']
},
// externals: [nodeExternals()],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
loader: require.resolve('file-loader'),
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.css$/],
options: {
name: 'assets/[name].[ext]'
}
}
]
}
};
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"name": "portal-components",
"name": "@deskpro/portal-components",
"version": "0.1.0",
"description": "Deskpro Portal Components",
"private": false,
"homepage": "https://deskpro.github.io/portal-components",
"main": "dist/index.js",
"module": "dist/index.js",
"files": [
"dist"
],
"dependencies": {
"@deskpro/js-utils": "^1.0.4",
"@deskpro/react-datepicker-hijri": "^1.5.0",
Expand All @@ -30,13 +35,15 @@
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"dist": "rm -rf ./dist && NODE_ENV=production webpack --config config/webpack.config.dist.js",
"lint": "eslint . --cache --cache-location=.cache/eslint --ext .js,.jsx",
"test": "node scripts/test.js --env=jsdom",
"travis-test": "npm run test -- --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -c .storybook -o .site",
"deploy-storybook": "storybook-to-ghpages",
"precommit": "lint-staged"
"precommit": "lint-staged",
"prepublish": "npm run dist"
},
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion src/Components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import Row from './Row';
import Submit from './Submit';
import TicketForm from './TicketForm';

import FieldLayout from './FieldLayout';

export {
Checkboxes,
DropDown,
Expand Down Expand Up @@ -53,6 +55,8 @@ export {
Form,
Row,
Submit,
TicketForm
TicketForm,

FieldLayout
};

3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import 'Components';
export * from './Components';
export * from './layouts/Layout';

0 comments on commit 223265f

Please sign in to comment.