mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-02 06:16:06 +00:00
reformat everything
This commit is contained in:
parent
bd531c91fc
commit
12fa008755
@ -1,4 +1,4 @@
|
|||||||
export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE'
|
export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
|
||||||
// I'm not sure, but I guess that if you use redux-devtools extension your APP_INIT should be look like:
|
// I'm not sure, but I guess that if you use redux-devtools extension your APP_INIT should be look like:
|
||||||
// export const APP_INIT = '@@INIT'
|
// export const APP_INIT = '@@INIT'
|
||||||
export const APP_INIT = '@@redux/INIT'
|
export const APP_INIT = '@@redux/INIT';
|
||||||
|
@ -18,7 +18,9 @@ export type CloseNotificationAction = {
|
|||||||
payload: Notification
|
payload: Notification
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NotificationsAction = ShowNotificationAction | CloseNotificationAction;
|
export type NotificationsAction =
|
||||||
|
| ShowNotificationAction
|
||||||
|
| CloseNotificationAction;
|
||||||
|
|
||||||
export function showNotification(
|
export function showNotification(
|
||||||
level: NOTIFICATION_LEVEL = 'info',
|
level: NOTIFICATION_LEVEL = 'info',
|
||||||
@ -35,7 +37,9 @@ export function showNotification(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function closeNotification(notification: Notification): CloseNotificationAction {
|
export function closeNotification(
|
||||||
|
notification: Notification
|
||||||
|
): CloseNotificationAction {
|
||||||
return {
|
return {
|
||||||
type: 'CLOSE_NOTIFICATION',
|
type: 'CLOSE_NOTIFICATION',
|
||||||
payload: notification
|
payload: notification
|
||||||
|
@ -2,14 +2,13 @@
|
|||||||
// feel free to replace with your code
|
// feel free to replace with your code
|
||||||
// (get, post are used in ApiServices)
|
// (get, post are used in ApiServices)
|
||||||
|
|
||||||
|
import { getLocalToken } from 'api/AuthSvc';
|
||||||
|
import config from 'config';
|
||||||
|
|
||||||
import {getLocalToken} from 'api/AuthSvc';
|
window.BASE_API = config.BASE_API;
|
||||||
import config from 'config'
|
|
||||||
|
|
||||||
window.BASE_API = config.BASE_API
|
|
||||||
|
|
||||||
function requestWrapper(method) {
|
function requestWrapper(method) {
|
||||||
return async function (url, data = null, params = {}) {
|
return async function(url, data = null, params = {}) {
|
||||||
if (method === 'GET') {
|
if (method === 'GET') {
|
||||||
// is it a GET?
|
// is it a GET?
|
||||||
// GET doesn't have data
|
// GET doesn't have data
|
||||||
@ -17,9 +16,9 @@ function requestWrapper(method) {
|
|||||||
data = null;
|
data = null;
|
||||||
} else if (data === Object(data)) {
|
} else if (data === Object(data)) {
|
||||||
// (data === Object(data)) === _.isObject(data)
|
// (data === Object(data)) === _.isObject(data)
|
||||||
data = JSON.stringify(data)
|
data = JSON.stringify(data);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`XHR invalid, check ${method} on ${url}`)
|
throw new Error(`XHR invalid, check ${method} on ${url}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// default params for fetch = method + (Content-Type)
|
// default params for fetch = method + (Content-Type)
|
||||||
@ -28,7 +27,7 @@ function requestWrapper(method) {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json; charset=UTF-8'
|
'Content-Type': 'application/json; charset=UTF-8'
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// check that req url is relative and request was sent to our domain
|
// check that req url is relative and request was sent to our domain
|
||||||
if (url.match(/^https?:\/\//gi) > -1) {
|
if (url.match(/^https?:\/\//gi) > -1) {
|
||||||
@ -43,14 +42,15 @@ function requestWrapper(method) {
|
|||||||
defaults.body = data;
|
defaults.body = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
let paramsObj = {...defaults, headers: {...params, ...defaults.headers}}
|
let paramsObj = {
|
||||||
|
...defaults,
|
||||||
|
headers: { ...params, ...defaults.headers }
|
||||||
|
};
|
||||||
|
|
||||||
return await fetch(url, paramsObj)
|
return await fetch(url, paramsObj).then(parseJSON).catch(err => {
|
||||||
.then(parseJSON)
|
console.error(err);
|
||||||
.catch((err) => {
|
|
||||||
console.error(err)
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// middlewares
|
// middlewares
|
||||||
@ -66,26 +66,25 @@ function requestWrapper(method) {
|
|||||||
async function parseJSON(res) {
|
async function parseJSON(res) {
|
||||||
let json;
|
let json;
|
||||||
try {
|
try {
|
||||||
json = await res.json()
|
json = await res.json();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {data: {}, ok: false}
|
return { data: {}, ok: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
// simplest validation ever, ahah :)
|
// simplest validation ever, ahah :)
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
return {data: json, ok: false}
|
return { data: json, ok: false };
|
||||||
}
|
}
|
||||||
// resultOK - is a function with side effects
|
// resultOK - is a function with side effects
|
||||||
// It removes ok property from result object
|
// It removes ok property from result object
|
||||||
return {data: json, ok: true}
|
return { data: json, ok: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const get = requestWrapper('GET');
|
||||||
export const get = requestWrapper('GET')
|
export const post = requestWrapper('POST');
|
||||||
export const post = requestWrapper('POST')
|
export const put = requestWrapper('PUT');
|
||||||
export const put = requestWrapper('PUT')
|
export const patch = requestWrapper('PATCH');
|
||||||
export const patch = requestWrapper('PATCH')
|
export const del = requestWrapper('DELETE');
|
||||||
export const del = requestWrapper('DELETE')
|
|
||||||
|
|
||||||
// USAGE:
|
// USAGE:
|
||||||
// get('https://www.google.com', {
|
// get('https://www.google.com', {
|
||||||
@ -109,10 +108,10 @@ export const del = requestWrapper('DELETE')
|
|||||||
*/
|
*/
|
||||||
export function resultOK(result) {
|
export function resultOK(result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
let ok = result.ok
|
let ok = result.ok;
|
||||||
delete result.ok
|
delete result.ok;
|
||||||
return ok //look at parseJSON
|
return ok; //look at parseJSON
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, {Component} from 'react'
|
import React, { Component } from 'react';
|
||||||
import {Provider} from 'react-redux'
|
import { Provider } from 'react-redux';
|
||||||
import {Router} from 'react-router'
|
import { Router } from 'react-router';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
export default class Root extends Component {
|
export default class Root extends Component {
|
||||||
@ -11,7 +11,7 @@ export default class Root extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {store, history, routes} = this.props;
|
const { store, history, routes } = this.props;
|
||||||
// key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395
|
// key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395
|
||||||
return (
|
return (
|
||||||
<Provider store={store} key={Math.random()}>
|
<Provider store={store} key={Math.random()}>
|
||||||
|
@ -1,27 +1,47 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const Help = () => (
|
const Help = () =>
|
||||||
<section className="container" style={{minHeight: '50%'}}>
|
<section className="container" style={{ minHeight: '50%' }}>
|
||||||
<div className="tab-content">
|
<div className="tab-content">
|
||||||
<article className="tab-pane help active">
|
<article className="tab-pane help active">
|
||||||
<h1 translate="NAV_Help">Help</h1>
|
<h1 translate="NAV_Help">Help</h1>
|
||||||
<article className="collapse-container">
|
<article className="collapse-container">
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
<li><h3><a
|
<li>
|
||||||
|
<h3>
|
||||||
|
<a
|
||||||
href="https://www.reddit.com/r/ethereum/comments/47nkoi/psa_check_your_ethaddressorg_wallets_and_any/d0eo45o"
|
href="https://www.reddit.com/r/ethereum/comments/47nkoi/psa_check_your_ethaddressorg_wallets_and_any/d0eo45o"
|
||||||
target="_blank"><span className="text-danger" translate="HELP_Warning">If you created a wallet -or- downloaded the repo before <strong>Dec. 31st, 2015</strong>, please check your wallets &
|
target="_blank"
|
||||||
download a new version of the repo. Click for details.</span></a></h3></li>
|
>
|
||||||
<li><h3>This
|
<span className="text-danger" translate="HELP_Warning">
|
||||||
|
If you created a wallet -or- downloaded the repo before{' '}
|
||||||
|
<strong>Dec. 31st, 2015</strong>, please check your
|
||||||
|
wallets &
|
||||||
|
download a new version of the repo. Click for details.
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<h3>
|
||||||
|
This
|
||||||
page is deprecated. Please check out our more up-to-date and
|
page is deprecated. Please check out our more up-to-date and
|
||||||
searchable <a href="https://myetherwallet.groovehq.com/help_center" target="_blank">Knowledge
|
searchable{' '}
|
||||||
Base. </a></h3></li>
|
<a
|
||||||
|
href="https://myetherwallet.groovehq.com/help_center"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
Knowledge
|
||||||
|
Base.{' '}
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>;
|
||||||
);
|
|
||||||
|
|
||||||
export default Help
|
export default Help;
|
||||||
|
@ -15,7 +15,8 @@ export default class GasField extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div className="row form-group">
|
<div className="row form-group">
|
||||||
<div className="col-sm-11 clearfix">
|
<div className="col-sm-11 clearfix">
|
||||||
<label>{translate('TRANS_gas')}{' '}
|
<label>
|
||||||
|
{translate('TRANS_gas')}{' '}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
className={`form-control ${isFinite(parseFloat(value)) &&
|
className={`form-control ${isFinite(parseFloat(value)) &&
|
||||||
|
@ -1 +1 @@
|
|||||||
export App from './App'
|
export App from './App';
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,10 @@ function decodeHTMLEntities(text) {
|
|||||||
var entities = [['amp', '&'], ['lt', '<'], ['gt', '>']];
|
var entities = [['amp', '&'], ['lt', '<'], ['gt', '>']];
|
||||||
|
|
||||||
for (var i = 0, max = entities.length; i < max; ++i)
|
for (var i = 0, max = entities.length; i < max; ++i)
|
||||||
text = text.replace(new RegExp('&' + entities[i][0] + ';', 'g'), entities[i][1]);
|
text = text.replace(
|
||||||
|
new RegExp('&' + entities[i][0] + ';', 'g'),
|
||||||
|
entities[i][1]
|
||||||
|
);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
@ -23,7 +26,11 @@ function linkify(mdString: string) {
|
|||||||
let i = 0;
|
let i = 0;
|
||||||
while (i + 1 < parts.length) {
|
while (i + 1 < parts.length) {
|
||||||
result.push(decodeHTMLEntities(parts[i]));
|
result.push(decodeHTMLEntities(parts[i]));
|
||||||
result.push(<a key={'linkify-' + key} href={parts[i + 2]} target="_blank">{parts[i + 1]}</a>);
|
result.push(
|
||||||
|
<a key={'linkify-' + key} href={parts[i + 2]} target="_blank">
|
||||||
|
{parts[i + 1]}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
key++;
|
key++;
|
||||||
i += 3;
|
i += 3;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -32,19 +32,31 @@ describe('markupToReact', () => {
|
|||||||
|
|
||||||
it('transforms link syntax', () => {
|
it('transforms link syntax', () => {
|
||||||
let value = '[foo](http://google.com)';
|
let value = '[foo](http://google.com)';
|
||||||
let expected = [<a key="linkify-0" href="http://google.com" target="_blank">foo</a>];
|
let expected = [
|
||||||
|
<a key="linkify-0" href="http://google.com" target="_blank">foo</a>
|
||||||
|
];
|
||||||
expect(markupToReact(value)).toEqual(expected);
|
expect(markupToReact(value)).toEqual(expected);
|
||||||
|
|
||||||
value = '[foo](http://google.com) bar';
|
value = '[foo](http://google.com) bar';
|
||||||
expected = [<a key="linkify-0" href="http://google.com" target="_blank">foo</a>, ' bar'];
|
expected = [
|
||||||
|
<a key="linkify-0" href="http://google.com" target="_blank">foo</a>,
|
||||||
|
' bar'
|
||||||
|
];
|
||||||
expect(markupToReact(value)).toEqual(expected);
|
expect(markupToReact(value)).toEqual(expected);
|
||||||
|
|
||||||
value = 'bar [foo](http://google.com)';
|
value = 'bar [foo](http://google.com)';
|
||||||
expected = ['bar ', <a key="linkify-0" href="http://google.com" target="_blank">foo</a>];
|
expected = [
|
||||||
|
'bar ',
|
||||||
|
<a key="linkify-0" href="http://google.com" target="_blank">foo</a>
|
||||||
|
];
|
||||||
expect(markupToReact(value)).toEqual(expected);
|
expect(markupToReact(value)).toEqual(expected);
|
||||||
|
|
||||||
value = 'bar [foo](http://google.com) baz';
|
value = 'bar [foo](http://google.com) baz';
|
||||||
expected = ['bar ', <a key="linkify-0" href="http://google.com" target="_blank">foo</a>, ' baz'];
|
expected = [
|
||||||
|
'bar ',
|
||||||
|
<a key="linkify-0" href="http://google.com" target="_blank">foo</a>,
|
||||||
|
' baz'
|
||||||
|
];
|
||||||
expect(markupToReact(value)).toEqual(expected);
|
expect(markupToReact(value)).toEqual(expected);
|
||||||
|
|
||||||
value = '[foo](http://google.com)[bar](http://google.ca)';
|
value = '[foo](http://google.com)[bar](http://google.ca)';
|
||||||
@ -71,5 +83,5 @@ describe('markupToReact', () => {
|
|||||||
let value = '&&';
|
let value = '&&';
|
||||||
let expected = '&&';
|
let expected = '&&';
|
||||||
expect(markupToReact(value)).toEqual(expected);
|
expect(markupToReact(value)).toEqual(expected);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'use strict'
|
'use strict';
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
@ -8,11 +8,17 @@ module.exports = {
|
|||||||
srcPath: path.join(__dirname, './../common'),
|
srcPath: path.join(__dirname, './../common'),
|
||||||
// add these dependencies to a standalone vendor bundle
|
// add these dependencies to a standalone vendor bundle
|
||||||
vendor: [
|
vendor: [
|
||||||
'react', 'react-dom', 'react-router', 'redux', 'react-router-redux', 'redux-thunk', 'whatwg-fetch'
|
'react',
|
||||||
|
'react-dom',
|
||||||
|
'react-router',
|
||||||
|
'redux',
|
||||||
|
'react-router-redux',
|
||||||
|
'redux-thunk',
|
||||||
|
'whatwg-fetch'
|
||||||
],
|
],
|
||||||
// enable babelrc
|
// enable babelrc
|
||||||
babel: {
|
babel: {
|
||||||
babelrc: true
|
babelrc: true
|
||||||
},
|
},
|
||||||
cssModules: false
|
cssModules: false
|
||||||
}
|
};
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
'use strict'
|
'use strict';
|
||||||
const chalk = require('chalk')
|
const chalk = require('chalk');
|
||||||
|
|
||||||
// this plugin if for loggin url after each time the compilation is done.
|
// this plugin if for loggin url after each time the compilation is done.
|
||||||
module.exports = class LogPlugin {
|
module.exports = class LogPlugin {
|
||||||
constructor(port) {
|
constructor(port) {
|
||||||
this.port = port
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
compiler.plugin('done', () => {
|
compiler.plugin('done', () => {
|
||||||
console.log(`> App is running at ${chalk.yellow(`http://localhost:${this.port}`)}\n`)
|
console.log(
|
||||||
})
|
`> App is running at ${chalk.yellow(`http://localhost:${this.port}`)}\n`
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
'use strict'
|
'use strict';
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
const express = require('express')
|
const express = require('express');
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack');
|
||||||
const webpackConfig = require('./webpack.dev')
|
const webpackConfig = require('./webpack.dev');
|
||||||
const config = require('./config')
|
const config = require('./config');
|
||||||
const LogPlugin = require('./log-plugin')
|
const LogPlugin = require('./log-plugin');
|
||||||
|
|
||||||
const app = express()
|
const app = express();
|
||||||
|
|
||||||
const port = config.port
|
const port = config.port;
|
||||||
webpackConfig.entry.client = [
|
webpackConfig.entry.client = [
|
||||||
'react-hot-loader/patch',
|
'react-hot-loader/patch',
|
||||||
'webpack-hot-middleware/client?reload=true',
|
'webpack-hot-middleware/client?reload=true',
|
||||||
'webpack/hot/only-dev-server',
|
'webpack/hot/only-dev-server',
|
||||||
webpackConfig.entry.client
|
webpackConfig.entry.client
|
||||||
]
|
];
|
||||||
|
|
||||||
webpackConfig.plugins.push(new LogPlugin(port))
|
webpackConfig.plugins.push(new LogPlugin(port));
|
||||||
|
|
||||||
let compiler
|
let compiler;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
compiler = webpack(webpackConfig)
|
compiler = webpack(webpackConfig);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err.message)
|
console.log(err.message);
|
||||||
process.exit(1)
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const devMiddleWare = require('webpack-dev-middleware')(compiler, {
|
const devMiddleWare = require('webpack-dev-middleware')(compiler, {
|
||||||
@ -36,22 +36,24 @@ const devMiddleWare = require('webpack-dev-middleware')(compiler, {
|
|||||||
'Access-Control-Allow-Methods': '*',
|
'Access-Control-Allow-Methods': '*',
|
||||||
'Access-Control-Allow-Headers': '*'
|
'Access-Control-Allow-Headers': '*'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
app.use(devMiddleWare)
|
app.use(devMiddleWare);
|
||||||
app.use(require('webpack-hot-middleware')(compiler, {
|
app.use(
|
||||||
|
require('webpack-hot-middleware')(compiler, {
|
||||||
log: console.log
|
log: console.log
|
||||||
}))
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const mfs = devMiddleWare.fileSystem
|
const mfs = devMiddleWare.fileSystem;
|
||||||
const file = path.join(webpackConfig.output.path, 'index.html')
|
const file = path.join(webpackConfig.output.path, 'index.html');
|
||||||
|
|
||||||
devMiddleWare.waitUntilValid()
|
devMiddleWare.waitUntilValid();
|
||||||
|
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
devMiddleWare.waitUntilValid(() => {
|
devMiddleWare.waitUntilValid(() => {
|
||||||
const html = mfs.readFileSync(file)
|
const html = mfs.readFileSync(file);
|
||||||
res.end(html)
|
res.end(html);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
app.listen(port)
|
app.listen(port);
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
'use strict'
|
'use strict';
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
const config = require('./config')
|
const config = require('./config');
|
||||||
|
|
||||||
const _ = module.exports = {}
|
const _ = (module.exports = {});
|
||||||
|
|
||||||
_.cwd = (file) => {
|
_.cwd = file => {
|
||||||
return path.join(process.cwd(), file || '')
|
return path.join(process.cwd(), file || '');
|
||||||
}
|
};
|
||||||
|
|
||||||
_.outputPath = path.join(__dirname, '../dist')
|
_.outputPath = path.join(__dirname, '../dist');
|
||||||
|
|
||||||
_.outputIndexPath = path.join(__dirname, '../dist/index.html')
|
_.outputIndexPath = path.join(__dirname, '../dist/index.html');
|
||||||
|
|
||||||
_.target = 'web'
|
_.target = 'web';
|
||||||
|
|
||||||
_.loadersOptions = () => {
|
_.loadersOptions = () => {
|
||||||
const isProd = process.env.NODE_ENV === 'production'
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
minimize: isProd,
|
minimize: isProd,
|
||||||
@ -24,5 +24,5 @@ _.loadersOptions = () => {
|
|||||||
context: process.cwd(),
|
context: process.cwd(),
|
||||||
babel: config.babel
|
babel: config.babel
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
'use strict'
|
'use strict';
|
||||||
process.env.NODE_ENV = 'development'
|
process.env.NODE_ENV = 'development';
|
||||||
|
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack');
|
||||||
const base = require('./webpack.base')
|
const base = require('./webpack.base');
|
||||||
const FriendlyErrors = require('friendly-errors-webpack-plugin')
|
const FriendlyErrors = require('friendly-errors-webpack-plugin');
|
||||||
|
|
||||||
base.devtool = 'source-map'
|
base.devtool = 'source-map';
|
||||||
base.module.loaders.push({
|
base.module.loaders.push(
|
||||||
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
loaders: ['style-loader', 'css-loader', 'resolve-url-loader']
|
loaders: ['style-loader', 'css-loader', 'resolve-url-loader']
|
||||||
},
|
},
|
||||||
@ -17,7 +18,8 @@ base.module.loaders.push({
|
|||||||
{
|
{
|
||||||
test: /\.less$/,
|
test: /\.less$/,
|
||||||
loaders: ['style-loader', 'css-loader', 'resolve-url-loader', 'less-loader']
|
loaders: ['style-loader', 'css-loader', 'resolve-url-loader', 'less-loader']
|
||||||
})
|
}
|
||||||
|
);
|
||||||
|
|
||||||
base.plugins.push(
|
base.plugins.push(
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
@ -26,6 +28,6 @@ base.plugins.push(
|
|||||||
new webpack.HotModuleReplacementPlugin(),
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
new webpack.NoEmitOnErrorsPlugin(),
|
new webpack.NoEmitOnErrorsPlugin(),
|
||||||
new FriendlyErrors()
|
new FriendlyErrors()
|
||||||
)
|
);
|
||||||
|
|
||||||
module.exports = base
|
module.exports = base;
|
||||||
|
@ -1,53 +1,45 @@
|
|||||||
'use strict'
|
'use strict';
|
||||||
process.env.NODE_ENV = 'production'
|
process.env.NODE_ENV = 'production';
|
||||||
|
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack');
|
||||||
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
const ProgressPlugin = require('webpack/lib/ProgressPlugin')
|
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
|
||||||
// const OfflinePlugin = require('offline-plugin')
|
// const OfflinePlugin = require('offline-plugin')
|
||||||
const base = require('./webpack.base')
|
const base = require('./webpack.base');
|
||||||
const config = require('./config')
|
const config = require('./config');
|
||||||
const fs = require('fs')
|
const fs = require('fs');
|
||||||
const distFolder = 'dist/';
|
const distFolder = 'dist/';
|
||||||
|
|
||||||
|
if (fs.existsSync(distFolder)) fs.rmdirSync(distFolder);
|
||||||
|
|
||||||
if (fs.existsSync(distFolder))
|
base.devtool = 'cheap-source-map';
|
||||||
fs.rmdirSync(distFolder)
|
|
||||||
|
|
||||||
base.devtool = 'cheap-source-map'
|
|
||||||
base.module.loaders.push(
|
base.module.loaders.push(
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
use: ExtractTextPlugin.extract(
|
use: ExtractTextPlugin.extract({
|
||||||
{
|
|
||||||
fallback: 'style-loader',
|
fallback: 'style-loader',
|
||||||
use: 'css-loader'
|
use: 'css-loader'
|
||||||
}
|
})
|
||||||
)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
use: ExtractTextPlugin.extract(
|
use: ExtractTextPlugin.extract({
|
||||||
{
|
|
||||||
fallback: 'style-loader',
|
fallback: 'style-loader',
|
||||||
use: ['css-loader', 'sass-loader']
|
use: ['css-loader', 'sass-loader']
|
||||||
}
|
})
|
||||||
)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.less$/,
|
test: /\.less$/,
|
||||||
use: ExtractTextPlugin.extract(
|
use: ExtractTextPlugin.extract({
|
||||||
{
|
|
||||||
fallback: 'style-loader',
|
fallback: 'style-loader',
|
||||||
use: ['css-loader', 'less-loader']
|
use: ['css-loader', 'less-loader']
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
|
||||||
)
|
|
||||||
// a white list to add dependencies to vendor chunk
|
// a white list to add dependencies to vendor chunk
|
||||||
base.entry.vendor = config.vendor
|
base.entry.vendor = config.vendor;
|
||||||
// use hash filename to support long-term caching
|
// use hash filename to support long-term caching
|
||||||
base.output.filename = '[name].[chunkhash:8].js'
|
base.output.filename = '[name].[chunkhash:8].js';
|
||||||
// add webpack plugins
|
// add webpack plugins
|
||||||
base.plugins.push(
|
base.plugins.push(
|
||||||
new ProgressPlugin(),
|
new ProgressPlugin(),
|
||||||
@ -77,7 +69,7 @@ base.plugins.push(
|
|||||||
// events: true
|
// events: true
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
)
|
);
|
||||||
|
|
||||||
// minimize webpack output
|
// minimize webpack output
|
||||||
base.stats = {
|
base.stats = {
|
||||||
@ -89,6 +81,6 @@ base.stats = {
|
|||||||
chunkModules: false,
|
chunkModules: false,
|
||||||
chunkOrigins: false,
|
chunkOrigins: false,
|
||||||
modules: false
|
modules: false
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = base
|
module.exports = base;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user