Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New repository for stackedit #1805

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
"presets": [
["env", { "modules": false }],
"stage-2"
],
"plugins": ["transform-runtime"],
"comments": false,
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-es2015-modules-commonjs", "dynamic-import-node"]
}
}
"presets": ["@babel/preset-env"],
"plugins": [
["@babel/transform-runtime"]
]
}
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

44 changes: 0 additions & 44 deletions .eslintrc.js

This file was deleted.

2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.vue
*.scss
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js

node_js:
- "12"
- "18"

services:
- docker
Expand Down
18 changes: 9 additions & 9 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
require('./check-versions')()
await import('./check-versions')

process.env.NODE_ENV = 'production'

var ora = require('ora')
var rm = require('rimraf')
var path = require('path')
var chalk = require('chalk')
var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')
const ora = require('ora');
const rm = require('rimraf');
const path = require('path');
const chalk = require('chalk');
const webpack = require('webpack');
const config = require('../config');
const webpackConfig = require('./webpack.prod.conf');

var spinner = ora('building for production...')
const spinner = ora('building for production...');
spinner.start()

rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
Expand Down
28 changes: 15 additions & 13 deletions build/check-versions.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../package.json')
var shell = require('shelljs')
import chalk from 'chalk'
import semver from 'semver'
import packageConfig from '../package.json' assert {type:'json'}
import shell from 'shelljs'
import child from 'child_process'
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
return child.execSync(cmd).toString().trim()
}

var versionRequirements = [
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
},
]
];

if (shell.which('npm')) {
versionRequirements.push({
Expand All @@ -22,10 +23,11 @@ if (shell.which('npm')) {
})
}

module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
export default function () {
let i;
const warnings = [];
for (i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i];
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
Expand All @@ -38,8 +40,8 @@ module.exports = function () {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
for (i = 0; i < warnings.length; i++) {
const warning = warnings[i];
console.log(' ' + warning)
}
console.log()
Expand Down
7 changes: 3 additions & 4 deletions build/dev-client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
import 'eventsource-polyfill'
import hotClient from 'webpack-hot-middleware'

hotClient.subscribe(function (event) {
hotClient.bind(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
Expand Down
78 changes: 39 additions & 39 deletions build/dev-server.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
require('./check-versions')()
import './check-versions.js'
import config from '../config/index.js'

var config = require('../config')
Object.keys(config.dev.env).forEach((key) => {
if (!process.env[key]) {
process.env[key] = JSON.parse(config.dev.env[key]);
}
});

var opn = require('opn')
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = require('./webpack.dev.conf')
import path from 'path'
import opn from 'opn'
import express from 'express'
import webpack from 'webpack'
import devMiddlewareFunc from 'webpack-dev-middleware'
import proxyMiddleware from 'http-proxy-middleware'
import webpackConfig from './webpack.dev.conf.js'
import webpackHot from 'webpack-hot-middleware'
import index from '../server/index.js'
import connectHistory from 'connect-history-api-fallback'

// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
const port = process.env.PORT || config.dev.port;
// automatically open browser, if not set will be false
var autoOpenBrowser = !!config.dev.autoOpenBrowser
const autoOpenBrowser = !!config.dev.autoOpenBrowser;
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable
const proxyTable = config.dev.proxyTable;

var app = express()
var compiler = webpack(webpackConfig)
const app = express();


const compiler = webpack(webpackConfig.res);

// StackEdit custom middlewares
require('../server')(app);
index(app);

var devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
quiet: true
})
const devMiddleware = devMiddlewareFunc(compiler, {
publicPath: webpackConfig.res.output.publicPath,
});

const hotMiddleware = webpackHot(compiler, {
log: () => {
}
});

var hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: () => {}
})
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})

// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
let options = proxyTable[context];
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(options.filter || context, options))
app.use(proxyMiddleware.createProxyMiddleware(options.filter || context, options))
})

// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())
app.use(connectHistory())

// serve webpack bundle output
app.use(devMiddleware)
Expand All @@ -64,15 +64,15 @@ app.use(devMiddleware)
app.use(hotMiddleware)

// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
app.use(staticPath, express.static('./static'))

var uri = 'http://localhost:' + port
const uri = 'http://localhost:' + port;

var _resolve
var readyPromise = new Promise(resolve => {
_resolve = resolve
})
let _resolve;
const readyPromise = new Promise(resolve => {
_resolve = resolve;
});

console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
Expand All @@ -84,9 +84,9 @@ devMiddleware.waitUntilValid(() => {
_resolve()
})

var server = app.listen(port)
const server = app.listen(port);

module.exports = {
export default {
ready: readyPromise,
close: () => {
server.close()
Expand Down
9 changes: 9 additions & 0 deletions build/eventBus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {TinyEmitter} from 'tiny-emitter'

const instance = new TinyEmitter()
export default {
$on: (...args) => instance.on(...args),
$once: (...args) => instance.once(...args),
$off: (...args) => instance.off(...args),
$emit: (...args) => instance.emit(...args),
}
44 changes: 23 additions & 21 deletions build/utils.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
import path from 'path'
import config from '../config/index.js'

exports.assetsPath = function (_path) {
var assetsSubDirectory = process.env.NODE_ENV === 'production'
const assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
: config.dev.assetsSubDirectory;
return path.posix.join(assetsSubDirectory, _path)
}

exports.cssLoaders = function (options) {
const cssLoaders = function (options) {
options = options || {}

var cssLoader = {
const cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
//minimize: process.env.NODE_ENV === 'production',
sourceMap: options.sourceMap
}
}
};

// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
var loaders = [cssLoader]
const loaders = [cssLoader];
if (loader) {
loaders.push({
loader: loader + '-loader',
Expand All @@ -32,18 +31,20 @@ exports.cssLoaders = function (options) {
})
}

// Extract CSS when that option is specified
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
return ['extract-loader'].concat(loaders)
// return ExtractTextPlugin.loader({
// use: loaders,
// fallback: 'vue-style-loader'
// })
} else {
return ['vue-style-loader'].concat(loaders)
}
}


// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
Expand All @@ -57,15 +58,16 @@ exports.cssLoaders = function (options) {
}

// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
const styleLoaders = function (options) {
const output = [];
const loaders = cssLoaders(options);
for (let extension in loaders) {
const loader = loaders[extension];
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
export default {styleLoaders,assetsPath,cssLoaders}
Loading