mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-27 21:05:53 +00:00
Developer improvements. Start using babel as the parser for eslint to add support for webpack's dynamic import syntax. Move most babel config into the babel build file to make sure nothing weird happens with eslint. Commit package-lock. Clean up gitignore a bit. Fix linting issues with the webpack build files.
This commit is contained in:
parent
41e80fd94c
commit
9ac7e8a209
11 changed files with 9071 additions and 23 deletions
3
.babelrc
3
.babelrc
|
@ -1,4 +1,3 @@
|
|||
{
|
||||
"presets": ["env"],
|
||||
"plugins": ["syntax-dynamic-import", "transform-runtime"]
|
||||
"plugins": ["syntax-dynamic-import"]
|
||||
}
|
|
@ -4,6 +4,7 @@ module.exports = {
|
|||
"es6": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8,
|
||||
"sourceType": "module"
|
||||
|
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,17 +1,10 @@
|
|||
node_modules
|
||||
npm-debug.log
|
||||
build
|
||||
dist
|
||||
Extension Building
|
||||
Old Files
|
||||
badges
|
||||
cdn
|
||||
|
||||
.idea
|
||||
*.iml
|
||||
script.js
|
||||
script.min.js
|
||||
*.min.css
|
||||
credentials.json
|
||||
|
||||
/socketserver/cmd/socketserver/socketserver
|
||||
credentials.json
|
9035
package-lock.json
generated
Normal file
9035
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -13,6 +13,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-eslint": "^8.2.2",
|
||||
"babel-loader": "^7.1.4",
|
||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import {EventEmitter} from 'utilities/events';
|
||||
import Module from 'utilities/module';
|
||||
import {has} from 'utilities/object';
|
||||
|
||||
|
||||
export default class Fine extends Module {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const CleanPlugin = require('clean-webpack-plugin');
|
||||
|
||||
/* global module __dirname */
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
|
@ -20,7 +21,6 @@ module.exports = {
|
|||
jsonpFunction: 'ffzWebpackJsonp'
|
||||
},
|
||||
plugins: [
|
||||
new CleanPlugin(['dist']),
|
||||
new webpack.ExtendedAPIPlugin()
|
||||
],
|
||||
module: {
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
const merge = require('webpack-merge');
|
||||
const common = require('./webpack.web.common.js');
|
||||
const path = require('path');
|
||||
|
||||
const CleanPlugin = require('clean-webpack-plugin');
|
||||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||
|
||||
/* global module __dirname */
|
||||
|
||||
const config = module.exports = merge(common, {
|
||||
devtool: 'source-map',
|
||||
|
||||
|
@ -11,11 +15,18 @@ const config = module.exports = merge(common, {
|
|||
rules: [{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'babel-loader'
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: ['env'],
|
||||
plugins: ['transform-runtime']
|
||||
}
|
||||
}
|
||||
}]
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new CleanPlugin(['dist/babel']),
|
||||
new UglifyJSPlugin({
|
||||
sourceMap: true,
|
||||
uglifyOptions: {
|
||||
|
@ -30,9 +41,9 @@ const config = module.exports = merge(common, {
|
|||
}
|
||||
}),
|
||||
new ManifestPlugin({
|
||||
map: (data) => {
|
||||
map: data => {
|
||||
if ( data.name.endsWith('.scss') )
|
||||
data.name = data.name.substr(0,data.name.length - 5) + '.css';
|
||||
data.name = `${data.name.substr(0,data.name.length - 5)}.css`;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -41,6 +52,7 @@ const config = module.exports = merge(common, {
|
|||
|
||||
output: {
|
||||
publicPath: '//cdn.frankerfacez.com/script/babel/',
|
||||
path: path.resolve(__dirname, 'dist/babel'),
|
||||
filename: '[name].[hash].js'
|
||||
}
|
||||
});
|
||||
|
@ -56,8 +68,8 @@ const config = module.exports = merge(common, {
|
|||
// But it works.
|
||||
|
||||
for(const rule of config.module.rules) {
|
||||
if ( rule.use )
|
||||
if ( Array.isArray(rule.use) )
|
||||
for(const use of rule.use)
|
||||
if ( use.options && use.options.name && use.options.name.startsWith('[name].') )
|
||||
use.options.name = '[name].[hash].' + use.options.name.slice(7)
|
||||
use.options.name = `[name].[hash].${use.options.name.slice(7)}`;
|
||||
}
|
|
@ -2,6 +2,8 @@ const path = require('path');
|
|||
const merge = require('webpack-merge');
|
||||
const common = require('./webpack.common.js');
|
||||
|
||||
/* global module __dirname */
|
||||
|
||||
module.exports = merge(common, {
|
||||
resolve: {
|
||||
alias: {
|
||||
|
|
|
@ -5,6 +5,8 @@ const common = require('./webpack.web.common.js');
|
|||
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
|
||||
/* global module */
|
||||
|
||||
module.exports = merge(common, {
|
||||
devtool: 'inline-source-map',
|
||||
|
||||
|
|
|
@ -4,13 +4,17 @@ const common = require('./webpack.web.common.js');
|
|||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||
const CleanPlugin = require('clean-webpack-plugin');
|
||||
|
||||
const uglify = require('uglify-es');
|
||||
|
||||
/* global module Buffer */
|
||||
|
||||
const config = module.exports = merge(common, {
|
||||
devtool: 'source-map',
|
||||
|
||||
plugins: [
|
||||
new CleanPlugin(['dist']),
|
||||
new UglifyJSPlugin({
|
||||
sourceMap: true,
|
||||
uglifyOptions: {
|
||||
|
@ -28,7 +32,7 @@ const config = module.exports = merge(common, {
|
|||
{
|
||||
from: './src/entry.js',
|
||||
to: 'script.min.js',
|
||||
transform: (content) => {
|
||||
transform: content => {
|
||||
const text = content.toString('utf8');
|
||||
const minified = uglify.minify(text);
|
||||
return (minified && minified.code) ? Buffer.from(minified.code) : content;
|
||||
|
@ -36,9 +40,9 @@ const config = module.exports = merge(common, {
|
|||
}
|
||||
]),
|
||||
new ManifestPlugin({
|
||||
map: (data) => {
|
||||
map: data => {
|
||||
if ( data.name.endsWith('.scss') )
|
||||
data.name = data.name.substr(0,data.name.length - 5) + '.css';
|
||||
data.name = `${data.name.substr(0,data.name.length - 5)}.css`;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -62,8 +66,8 @@ const config = module.exports = merge(common, {
|
|||
// But it works.
|
||||
|
||||
for(const rule of config.module.rules) {
|
||||
if ( rule.use )
|
||||
if ( Array.isArray(rule.use) )
|
||||
for(const use of rule.use)
|
||||
if ( use.options && use.options.name && use.options.name.startsWith('[name].') )
|
||||
use.options.name = '[name].[hash].' + use.options.name.slice(7)
|
||||
use.options.name = `[name].[hash].${use.options.name.slice(7)}`;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue