Skip to content

Commit

Permalink
track project with git
Browse files Browse the repository at this point in the history
  • Loading branch information
ciolt committed Jan 3, 2019
0 parents commit 3a561d6
Show file tree
Hide file tree
Showing 77 changed files with 15,418 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-runtime"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["istanbul"]
}
}
}
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
core/*.js
core/*/*.js
build/*.js
31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// https://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
globals: {
"chrome": true
// chrome: true
},
env: {
browser: true,
},
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# IDE
.vscode/

# dependencies
node_modules/

# logs
npm-debug.log
yarn.lock

# Webpack build
build/
8 changes: 8 additions & 0 deletions .postcssrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://github.com/michael-ciniawsky/postcss-load-config

module.exports = {
"plugins": {
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}
13 changes: 13 additions & 0 deletions core/page.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/css/fonts.css"/>
<title><%= htmlWebpackPlugin.options.title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="root"></div>
</body>
</html>
60 changes: 60 additions & 0 deletions core/tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

exports.htmlPage = (title, filename, chunks, template) => new HtmlWebpackPlugin({
title,
hash: true,
cache: true,
inject: 'body',
filename: './pages/' + filename + '.html',
template: template || path.resolve(__dirname, './page.ejs'),
appMountId: 'app',
chunks
})


exports.cssLoaders = (options = {}) => {
let loaders = {}
let prePprocessors = {
css: {},
postcss: {},
less: { loader: 'less'},
sass: { loader:'sass', options: { indentedSyntax: true } },
scss: { loader:'sass' },
stylus: { loader: 'stylus' },
styl: { loader: 'stylus' }
}
for(let key in prePprocessors) {
let loader = [{
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production'
}
}]
if (prePprocessors[key].loader) {
loader.push({
loader: prePprocessors[key].loader + '-loader',
options: Object.assign({}, prePprocessors[key].options, { sourceMap: options.sourceMap })
})
}
if (options.extract) {
loaders[key] = ExtractTextPlugin.extract({ use: loader, fallback: 'vue-style-loader' })
} else {
loaders[key] = ['vue-style-loader'].concat(loader)
}
}
return loaders;
}
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
100 changes: 100 additions & 0 deletions core/webpack.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
const path = require('path')
const webpack = require('webpack')
const ChromeReloadPlugin = require('wcer')
const {cssLoaders, htmlPage} = require('./tools')
const CopyWebpackPlugin = require('copy-webpack-plugin')

let resolve = dir => path.join(__dirname, '..', 'src', dir)
module.exports = {
entry: {
popup: resolve('./popup'),
options: resolve('./options'),
background: resolve('./backend'),
auth: resolve('./auth')
},
output: {
path: path.join(__dirname, '..', 'build'),
publicPath: '/',
filename: 'js/[name].js',
chunkFilename: 'js/[id].[name].js?[hash]',
library: '[name]'
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src')
}
},
module: {
rules: [
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [path.join(__dirname, '..', 'src'), path.join(__dirname, '..', 'test')],
options: {
formatter: require('eslint-friendly-formatter')
}
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
extractCSS: true,
loaders: {
...cssLoaders(),
js: { loader: 'babel-loader' }
},
transformToRequire: {
video: 'src',
source: 'src',
img: 'src',
image: 'xlink:href'
}
}
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [path.join(__dirname, '..', 'src'), path.join(__dirname, '..', 'test')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'img/[name].[hash:7].[ext]'
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'media/[name].[hash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'fonts/[name].[hash:7].[ext]'
}
}
]
},
plugins: [
htmlPage('QuickToot', 'popup', ['popup']),
htmlPage('QuickToot Options', 'options', ['options']),
htmlPage('Account Authentication Passthrough', 'auth', ['auth']),
htmlPage('QuickToot Background', 'background', ['background']),
new CopyWebpackPlugin([{ from: path.join(__dirname, '..', 'static') }]),
new ChromeReloadPlugin({
port: 9090,
manifest: path.join(__dirname, '..', 'src', 'manifest.js')
})
],
performance: { hints: false }
}
21 changes: 21 additions & 0 deletions core/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

const webpack = require('webpack')
const merge = require('webpack-merge')
const baseWebpack = require('./webpack.base')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const {styleLoaders} = require('./tools')
module.exports = merge(baseWebpack, {
// cheap-module-eval-source-map быстрее для разработки
watch: true,
module: {
rules: styleLoaders({ sourceMap: false })
},
devtool: '#cheap-module-eval-source-map',
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"development"'
}),
new FriendlyErrorsPlugin()
]
})
47 changes: 47 additions & 0 deletions core/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const baseWebpack = require('./webpack.base')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const {styleLoaders} = require('./tools')
module.exports = merge(baseWebpack, {
devtool: '#cheap-module-eval-source-map',
module: {
rules: styleLoaders({ extract: true, sourceMap: true })
},
plugins: [
new CleanWebpackPlugin(['build/*.*']),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true
}
}),
new ExtractTextPlugin({
filename: 'css/[name].[contenthash].css'
}),
new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['vendor']
})
]
})
Loading

0 comments on commit 3a561d6

Please sign in to comment.