Skip to content

Commit

Permalink
chore(style): use 2 spaces for indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Oct 30, 2016
1 parent 08fe9fd commit c7ca2a7
Show file tree
Hide file tree
Showing 24 changed files with 684 additions and 688 deletions.
6 changes: 1 addition & 5 deletions .editorconfig
Expand Up @@ -9,7 +9,7 @@ root = true

# change these settings to your own preference
indent_style = space
indent_size = 4
indent_size = 2

# we recommend you to keep these unchanged
end_of_line = lf
Expand All @@ -19,7 +19,3 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{package,bower}.json]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -158,7 +158,7 @@
"func-style": 0,
"id-length": 0,
"id-match": 0,
"indent": [1, 4],
"indent": [1, 2],
"jsx-quotes": [1, "prefer-single"],
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": 1,
Expand Down
30 changes: 15 additions & 15 deletions src/babelrc.js
@@ -1,18 +1,18 @@
export default {
presets: [
[ require.resolve('babel-preset-es2015'), { 'modules': false } ],
require.resolve('babel-preset-react'),
require.resolve('babel-preset-stage-1'),
],
plugins: [
require.resolve('babel-plugin-transform-runtime'),
],
env: {
production: {
plugins: [
require.resolve('babel-plugin-transform-react-constant-elements'),
require.resolve('babel-plugin-transform-react-inline-elements'),
]
}
presets: [
[ require.resolve('babel-preset-es2015'), { modules: false } ],
require.resolve('babel-preset-react'),
require.resolve('babel-preset-stage-1'),
],
plugins: [
require.resolve('babel-plugin-transform-runtime'),
],
env: {
production: {
plugins: [
require.resolve('babel-plugin-transform-react-constant-elements'),
require.resolve('babel-plugin-transform-react-inline-elements'),
]
}
}
};
24 changes: 12 additions & 12 deletions src/bundler.js
Expand Up @@ -2,20 +2,20 @@ import bundler from './configure-bundler';
import runCompilerAsync from './run-compiler-async';

export default async function(options) {
const compiler = await bundler({ ...options, devtool: options.sourcemaps ? 'source-map' : null });
const status = await runCompilerAsync(compiler);
const compiler = await bundler({ ...options, devtool: options.sourcemaps ? 'source-map' : null });
const status = await runCompilerAsync(compiler);

if (!options.quiet) {
console.log(status.toString({
colors: true
}));
}
if (!options.quiet) {
console.log(status.toString({
colors: true
}));
}

const result = status.toJson();
const result = status.toJson();

if (result.errors.length) {
throw result.errors;
}
if (result.errors.length) {
throw result.errors;
}

return result;
return result;
}
36 changes: 18 additions & 18 deletions src/configure-bundler.js
Expand Up @@ -5,30 +5,30 @@ import configure from './configure-webpack';
import existsFileAsync from './exists-file-async';

export default async function(options) {
const WORKINGDIR = options.root;
const OUTPUTFILE = options.output || '[name].bundle.js';
const WORKINGDIR = options.root;
const OUTPUTFILE = options.output || '[name].bundle.js';

const files = await Promise.all(
const files = await Promise.all(
options.entry.map(
f => existsFileAsync(fs, path.join(WORKINGDIR, f))
)
);

const entry = {};
const entry = {};

for (const f of files) {
entry[path.basename(f, '.js')] = f;
}
for (const f of files) {
entry[path.basename(f, '.js')] = f;
}

return webpack(configure({
context: WORKINGDIR,
devtool: options.devtool ? options.devtool : false,
production: options.production,
output: {
path: WORKINGDIR,
filename: OUTPUTFILE,
sourceMapFilename: OUTPUTFILE + '.map'
},
entry,
}));
return webpack(configure({
context: WORKINGDIR,
devtool: options.devtool ? options.devtool : false,
production: options.production,
output: {
path: WORKINGDIR,
filename: OUTPUTFILE,
sourceMapFilename: OUTPUTFILE + '.map'
},
entry,
}));
}
144 changes: 72 additions & 72 deletions src/configure-webpack.js
Expand Up @@ -9,86 +9,86 @@ const CSS_LOADER = 'css-loader?modules&importLoaders=2&sourceMap&localIdentName=
const SASS_LOADER = 'sass-loader?sourceMap';
const LESS_LOADER = 'less-loader?sourceMap';
const STYLE_LOADERS = [
'style-loader',
CSS_LOADER,
{
loader: 'postcss-loader',
options: {
plugins() {
return [ autoprefixer ];
},
},
}
'style-loader',
CSS_LOADER,
{
loader: 'postcss-loader',
options: {
plugins() {
return [ autoprefixer ];
},
},
}
];

export default (options) => ({
context: options.context,
entry: options.entry,
output: options.output,
devtool: options.devtool,
context: options.context,
entry: options.entry,
output: options.output,
devtool: options.devtool,

plugins: [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: options.production ? '"production"' : '"developement"'
}
}),
new webpack.LoaderOptionsPlugin({
minimize: !!options.production,
debug: !options.production
}),
]
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: options.production ? '"production"' : '"developement"'
}
}),
new webpack.LoaderOptionsPlugin({
minimize: !!options.production,
debug: !options.production
}),
]
.concat(options.production ? [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
sourceMap: !!options.devtool,
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
sourceMap: !!options.devtool,
}),
] : [])
.concat(options.plugins || []),

module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: BABEL_LOADER,
},
{
test: /\.json$/,
loader: 'json',
},
{
test: /\.css$/,
use: STYLE_LOADERS,
},
{
test: /\.less$/,
use: [ ...STYLE_LOADERS, LESS_LOADER ],
},
{
test: /\.scss$/,
use: [ ...STYLE_LOADERS, SASS_LOADER ],
},
{
test: /\.(gif|jpg|png|webp|svg)$/,
loader: 'url?limit=25000',
},
],
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: BABEL_LOADER,
},
{
test: /\.json$/,
loader: 'json',
},
{
test: /\.css$/,
use: STYLE_LOADERS,
},
{
test: /\.less$/,
use: [ ...STYLE_LOADERS, LESS_LOADER ],
},
{
test: /\.scss$/,
use: [ ...STYLE_LOADERS, SASS_LOADER ],
},
{
test: /\.(gif|jpg|png|webp|svg)$/,
loader: 'url?limit=25000',
},
],
},

resolveLoader: {
modules: [
path.join(CURRENTDIR, 'node_modules'),
path.resolve(options.context, 'node_modules'),
],
},
resolveLoader: {
modules: [
path.join(CURRENTDIR, 'node_modules'),
path.resolve(options.context, 'node_modules'),
],
},

resolve: {
modules: [
path.join(CURRENTDIR, 'node_modules'),
path.resolve(options.context, 'node_modules'),
],
}
resolve: {
modules: [
path.join(CURRENTDIR, 'node_modules'),
path.resolve(options.context, 'node_modules'),
],
}
});
16 changes: 8 additions & 8 deletions src/exists-file-async.js
@@ -1,11 +1,11 @@
export default function(fs, file) {
return new Promise((resolve, reject) => {
fs.access(file, fs.R_OK, error => {
if (error) {
reject(error);
} else {
resolve(file);
}
});
return new Promise((resolve, reject) => {
fs.access(file, fs.R_OK, error => {
if (error) {
reject(error);
} else {
resolve(file);
}
});
});
}
2 changes: 1 addition & 1 deletion src/format-error.js
@@ -1,5 +1,5 @@
export default function(error) {
return `
return `
/* show error response on build fail */
document.body.onload = function() {
document.body.style.background = 'rgb(255, 221, 221)';
Expand Down
2 changes: 1 addition & 1 deletion src/format-html.js
@@ -1,5 +1,5 @@
export default function(script) {
return `
return `
<!DOCTYPE html>
<head>
<meta charset="utf-8">
Expand Down

0 comments on commit c7ca2a7

Please sign in to comment.