Skip to content

Commit

Permalink
build: Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
reintroducing committed Aug 12, 2019
0 parents commit 7ba5630
Show file tree
Hide file tree
Showing 14 changed files with 15,366 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.log
.DS_Store
.idea
.env
.sass-cache
.venv
.vscode
*.code-workspace
node_modules
_internal
dist
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_internal
./.eslintrc
./.npmrc
./.nvmrc
commitlint.config.js
/docs
/website
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v12.8.0
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 0.0.2 - 08/11/2019
## Miscellaneous Updates
* [[c8e508c0](https://github.com/reintroducing/rsr/commit/c8e508c0)] - `ci:` Add .npmignore (Matt Przybylski)
* [[24fffed1](https://github.com/reintroducing/rsr/commit/24fffed1)] - `ci:` Add commitlint config (Matt Przybylski)
* [[3917ada7](https://github.com/reintroducing/rsr/commit/3917ada7)] - added node_modules to gitignore (Matt Przybylski)
* [[86dca724](https://github.com/reintroducing/rsr/commit/86dca724)] - added gitignore (Matt Przybylski)
* [[2814c922](https://github.com/reintroducing/rsr/commit/2814c922)] - initial commit (Matt Przybylski)
* [[c9399239](https://github.com/reintroducing/rsr/commit/c9399239)] - Initial commit (Matt Przybylski)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To use:
1) `npm link` first in the root.
1) Now can run `rsr` command in terminal.
26 changes: 26 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node
const arg = require('arg');
const chalk = require('chalk');
const spawn = require('cross-spawn');

const args = arg({
'--event': String, // rsr --event=start
'-e': '--event', // rsr -e start
});
const script = args['--event'];

switch (script) {
case 'start':
case 'test':
case 'build':
spawn.sync(
'node',
[require.resolve(`../scripts/${script}`)],
{stdio: 'inherit'}
);
break;

default:
console.log(chalk.red(`The script ${script} does not exist.`));
break;
}
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@spothero/commitlint-config']
};
214 changes: 214 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
const path = require('path');
const del = require('del');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const eslintFriendlyFormatter = require('eslint-friendly-formatter');
const postCssImport = require('postcss-import');
const postcssPresetEnv = require('postcss-preset-env');
const flexbugsFixes = require('postcss-flexbugs-fixes');

module.exports = function(mode = 'development') {
const isDev = (mode === 'development' || mode === 'test');
const dist = path.resolve(process.cwd(), 'dist');
const src = path.resolve(process.cwd(), 'src');
const entry = [`${src}/index.js`];
const stats = {
children: false,
chunkModules: false,
chunks: false,
colors: true,
hash: false,
modules: false,
performance: false,
timings: true,
};

if (isDev) {
entry.unshift('react-hot-loader/patch');
}

del.sync(dist);

return {
mode: (isDev)
? 'development'
: 'production',
target: 'web',
devtool: (isDev)
? 'cheap-module-source-map'
: 'source-map',
entry,
output: {
filename: `js/[name]${(isDev) ? '' : '-[hash]'}.js`,
path: `${dist}`,
...(isDev) && {
publicPath: '/',
},
},
plugins: [
new StyleLintPlugin(),
// new StyleLintPlugin({
// // configBasedir: process.cwd(),
// configBasedir: path.resolve(__dirname, '../'),
// }),
new HtmlWebpackPlugin({
filename: `${dist}/index.html`,
template: `${src}/index.html`,
}),
new MiniCssExtractPlugin({
filename: `css/[name]${(isDev) ? '' : '-[hash]'}.css`,
chunkFilename: (isDev)
? 'css/[name]-[id].css'
: 'css/[name]-[contenthash].css',
}),
new BundleAnalyzerPlugin({
analyzerMode: (isDev) ? 'static' : 'disabled',
openAnalyzer: false,
}),
],
resolve: {
alias: {
...(isDev) && {
'react-dom': '@hot-loader/react-dom',
},
},
modules: [
'node_modules',
src,
],
extensions: [
'.js',
'.jsx',
'.json',
],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
'babel-loader',
{
loader: 'eslint-loader',
options: {
formatter: eslintFriendlyFormatter,
emitError: true,
emitWarning: true,
},
},
],
},
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: isDev,
publicPath: (resourcePath, context) => {
return `${path.relative(dist, context)}/`;
},
},
},
{
loader: 'css-loader',
options: {
importLoaders: 2,
modules: {
localIdentName: `[name]-[local]${(isDev) ? '' : '-[hash:base64]'}`,
},
sourceMap: isDev,
},
},
{
loader: 'postcss-loader',
options: {
plugins: [
postCssImport(),
flexbugsFixes(),
postcssPresetEnv(),
],
},
},
{
loader: 'sass-loader',
options: {
sourceMap: isDev,
},
},
{
loader: 'sass-resources-loader',
options: {
resources: 'src/common/_resources.scss',
},
},
],
},
{
test: /\.(png|svg|jpe?g|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: `[folder]/[name]${(isDev) ? '' : '-[contenthash]'}.[ext]`,
outputPath: 'img',
},
},
{
loader: 'image-webpack-loader',
options: {
disable: isDev,
},
},
],
},
],
},
stats,
...(isDev) && {
devServer: {
historyApiFallback: true,
hot: true,
open: true,
publicPath: '/',
stats,
writeToDisk: true,
},
},
performance: {
hints: false,
},
optimization: {
...(!isDev) && {
minimizer: [
new OptimizeCssAssetsPlugin({
cssProcessorPluginOptions: {
preset: ['default', {
discardComments: {
removeAll: true,
},
}],
},
}),
new TerserPlugin({
parallel: true,
sourceMap: true,
terserOptions: {
compress: {
warnings: false,
},
output: {
comments: false,
},
},
}),
],
},
},
};
}
Loading

0 comments on commit 7ba5630

Please sign in to comment.