Commit f18e0c30 authored by Tasso Evangelista's avatar Tasso Evangelista Committed by Guilherme Gazzo

Fix some build issues (#90)

parent 94f8be16
......@@ -2,6 +2,5 @@
/build
/stats.json
/*.log
*.lock
coverage
package-lock.json
......@@ -4,27 +4,27 @@
``` bash
# install dependencies
npm install
yarn
# serve with hot reload at localhost:8080
npm run dev
yarn dev
# build for production with minification
npm run build
yarn build
# test the production build locally
npm run serve
yarn serve
# run tests with jest and preact-render-spy
npm run test
yarn test
# run the storybook
npm run storybook
```
### before commit run
```bash
npm run i18n
yarn storybook
# before commit run
yarn i18n
```
## Screens:
![image](https://user-images.githubusercontent.com/5263975/44279585-497b2980-a228-11e8-81a2-36bc3389549e.png)
![image](https://user-images.githubusercontent.com/5263975/44279599-5730af00-a228-11e8-8873-553ef53ee25a.png)
......
{
"name": "rocket.chat.livechat",
"version": "0.0.1-1",
"license": "MIT",
"scripts": {
"start": "if-env NODE_ENV=production && npm run -s serve || npm run -s dev",
"build": "GENERATE_SOURCEMAP=false preact build --json --no-prerender --optimize-minimize",
"serve": "preact build --json --no-prerender --optimize-minimize && preact serve",
"dev": "preact watch",
"lint": "eslint src",
"test": "jest ./tests",
"coverage": "jest --coverage",
"storybook": "start-storybook -p 9001 -c .storybook",
"i18n": "i18nline synch && node_modules/.bin/eslint --fix src/i18n/index.js",
"deploy-storybook": "storybook-to-ghpages"
},
"eslintIgnore": [
"build/*"
],
"i18n": {
"autoTranslateTags": [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"p"
],
"ignorePatterns": [
"story.js"
]
},
"devDependencies": {
"@storybook/addon-actions": "^3.4.11",
"@storybook/addon-centered": "^3.4.10",
"@storybook/addon-console": "^1.1.0",
"@storybook/addon-knobs": "^3.4.10",
"@storybook/addon-options": "^3.4.10",
"@storybook/addon-viewport": "^3.4.10",
"@storybook/react": "^3.4.10",
"@storybook/storybook-deployer": "^2.3.0",
"css-loader": "^1.0.0",
"desvg": "^1.0.2",
"desvg-loader": "^0.1.0",
"eslint": "^4.9.0",
"eslint-config-synacor": "^2.0.2",
"i18nline": "^2.0.1",
"identity-obj-proxy": "^3.0.0",
"if-env": "^1.0.0",
"image-webpack-loader": "^4.3.1",
"jest": "^21.2.1",
"lorem-ipsum": "^1.0.6",
"node-sass": "^4.9.3",
"preact-cli": "^3.0.0-next.14",
"preact-compat": "^3.18.4",
"preact-render-spy": "^1.2.1",
"sass-loader": "^7.1.0",
"style-loader": "^0.22.1",
"svg-loader": "0.0.2",
"webpack": "^3.12.0",
"webpack-bundle-analyzer": "^3.0.2"
},
"dependencies": {
"@kossnocorp/desvg": "^0.2.0",
"@rocket.chat/sdk": "^1.0.0-alpha.18",
"date-fns": "^1.29.0",
"desvg": "^1.0.2",
"desvg-loader": "^0.1.0",
"fast-async": "^6.3.8",
"i18n": "^0.8.3",
"i18nline": "^2.0.1",
"markdown-it": "^8.4.2",
"msgpack": "^1.0.2",
"preact": "^8.2.6",
"preact-context": "^1.1.1",
"preact-i18nline": "^2.0.0",
"preact-router": "^2.5.7",
"tiny-events": "^1.0.1"
},
"jest": {
"verbose": true,
"setupFiles": [
"<rootDir>/src/tests/__mocks__/browserMocks.js"
],
"testURL": "http://localhost:8080",
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/tests/__mocks__/fileMock.js",
"\\.(css|less|scss)$": "identity-obj-proxy",
"^./style$": "identity-obj-proxy",
"^preact$": "<rootDir>/node_modules/preact/dist/preact.min.js",
"^react$": "preact-compat",
"^react-dom$": "preact-compat",
"^create-react-class$": "preact-compat/lib/create-react-class",
"^react-addons-css-transition-group$": "preact-css-transition-group"
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie < 11"
]
"name": "rocket.chat.livechat",
"version": "0.0.1-1",
"license": "MIT",
"scripts": {
"start": "if-env NODE_ENV=production && npm run -s serve || npm run -s dev",
"build": "GENERATE_SOURCEMAP=false preact build --no-prerender --optimize-minimize",
"serve": "preact build --no-prerender --optimize-minimize && preact serve",
"dev": "preact watch",
"lint": "eslint src",
"test": "jest ./tests",
"coverage": "jest --coverage",
"storybook": "start-storybook -p 9001 -c .storybook",
"i18n": "i18nline synch && node_modules/.bin/eslint --fix src/i18n/index.js",
"deploy-storybook": "storybook-to-ghpages",
"bundle-analyzer": "webpack-bundle-analyzer build/stats.json"
},
"eslintIgnore": [
"build/*"
],
"i18n": {
"autoTranslateTags": [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"p"
],
"ignorePatterns": [
"story.js"
]
},
"devDependencies": {
"@storybook/addon-actions": "^4.1.6",
"@storybook/addon-centered": "^4.1.6",
"@storybook/addon-console": "^1.1.0",
"@storybook/addon-knobs": "^4.1.6",
"@storybook/addon-options": "^4.1.6",
"@storybook/addon-viewport": "^4.1.6",
"@storybook/react": "^4.1.6",
"@storybook/storybook-deployer": "^2.3.0",
"css-loader": "^1.0.0",
"desvg-loader": "^0.1.0",
"eslint": "^4.9.0",
"eslint-config-synacor": "^2.0.2",
"identity-obj-proxy": "^3.0.0",
"if-env": "^1.0.0",
"image-webpack-loader": "^4.3.1",
"jest": "^21.2.1",
"lorem-ipsum": "^1.0.6",
"node-sass": "^4.9.3",
"preact-cli": "^3.0.0-next.14",
"preact-compat": "^3.18.4",
"preact-render-spy": "^1.2.1",
"sass-loader": "^7.1.0",
"style-loader": "^0.22.1",
"svg-loader": "0.0.2",
"webpack-bundle-analyzer": "^3.0.2"
},
"dependencies": {
"@kossnocorp/desvg": "^0.2.0",
"@rocket.chat/sdk": "^1.0.0-alpha.19",
"date-fns": "^1.29.0",
"desvg": "^1.0.2",
"fast-async": "^6.3.8",
"i18n": "^0.8.3",
"i18nline": "^2.0.1",
"markdown-it": "^8.4.2",
"msgpack": "^1.0.2",
"preact": "^8.2.6",
"preact-context": "^1.1.1",
"preact-i18nline": "^2.0.0",
"preact-router": "^2.5.7",
"tiny-events": "^1.0.1"
},
"jest": {
"verbose": true,
"setupFiles": [
"<rootDir>/src/tests/__mocks__/browserMocks.js"
],
"testURL": "http://localhost:8080",
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/tests/__mocks__/fileMock.js",
"\\.(css|less|scss)$": "identity-obj-proxy",
"^./style$": "identity-obj-proxy",
"^preact$": "<rootDir>/node_modules/preact/dist/preact.min.js",
"^react$": "preact-compat",
"^react-dom$": "preact-compat",
"^create-react-class$": "preact-compat/lib/create-react-class",
"^react-addons-css-transition-group$": "preact-css-transition-group"
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie < 11"
]
}
......@@ -10,6 +10,10 @@ export default (config/* , env, helpers */) => {
config.mode = 'production';
config.performance = {
hints: false,
};
config.optimization = {
sideEffects: false,
minimizer: [
......@@ -106,7 +110,11 @@ export default (config/* , env, helpers */) => {
'process.title': 'browser',
};
config.plugins.push(new BundleAnalyzerPlugin({ openAnalyzer: false }));
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
statsFilename: 'stats.json',
}));
return config;
};
import { storiesOf } from '@storybook/react';
import centered from '@storybook/addon-centered';
import { withKnobs } from '@storybook/addon-knobs';
import { withKnobs, object } from '@storybook/addon-knobs';
import Button from '../Button';
import { PopoverContainer, PopoverTrigger } from '.';
import { object } from '@storybook/addon-knobs/dist/vue';
storiesOf('Components|Popover', module)
......
......@@ -4,31 +4,37 @@ const webpack = require('webpack');
const patchBabelLoader = (config) => {
const babelLoader = config.module.rules.find(({ loader }) => /babel-loader/.test(loader));
const { loader, test, enforce, include, exclude, options, query } = babelLoader;
config.module.rules = config.module.rules.map((rule) => {
if (rule.loader === 'babel-loader') {
const { enforce, test, loader, options } = rule;
config.module.rules = [
...config.module.rules.filter((loader) => loader !== babelLoader),
{
test,
enforce,
include,
exclude,
use: [
{ loader, options: options || query },
{ loader: 'preact-i18nline/webpack-loader' },
],
},
];
return {
enforce,
test,
use: [
{ loader, options },
{ loader: 'preact-i18nline/webpack-loader' },
],
};
}
return config;
if (Array.isArray(rule.use) && rule.use.find(({ loader }) => loader === 'babel-loader')) {
return {
...rule,
use: [
...rule.use,
{ loader: 'preact-i18nline/webpack-loader' },
],
};
}
return rule;
});
};
const patchFileLoader = (config) => {
const fileLoader = config.module.rules.find(({ loader }) => /file-loader|url-loader/.test(loader));
fileLoader.test = /\.(woff2?|ttf|eot|jpe?g|png|gif|mp4|mov|ogg|webm)(\?.*)?$/i;
return config;
};
module.exports = (config/* , env */) => {
......@@ -49,8 +55,8 @@ module.exports = (config/* , env */) => {
}
);
config = patchBabelLoader(config);
config = patchFileLoader(config);
patchBabelLoader(config);
patchFileLoader(config);
config.module.rules.push({
test: /\.svg$/,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment