Skip to content

Commit

Permalink
update generator
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jun 12, 2018
1 parent 4ddb308 commit 3a2d482
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 134 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ node_modules/
# Build-related directories
dist/
docs/api/
test/dist/
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@
"main": "dist/videojs-vr.cjs.js",
"module": "dist/videojs-vr.es.js",
"generator-videojs-plugin": {
"version": "6.0.5"
"version": "6.0.8"
},
"scripts": {
"prebuild": "npm run clean",
"build": "npm-run-all -p build:*",
"build:css": "postcss --verbose -o dist/videojs-vr.css --config scripts/postcss.config.js src/plugin.css",
"build:js": "rollup -c scripts/rollup.config.js",
"build:lang": "vjslang --dir dist/lang",
"clean": "rimraf dist",
"postclean": "mkdirp dist",
"clean": "rimraf dist test/dist",
"postclean": "mkdirp dist test/dist",
"docs": "npm-run-all docs:*",
"docs:api": "jsdoc src -r -c scripts/jsdoc.json -d docs/api",
"docs:toc": "doctoc README.md",
"lint": "vjsstandard",
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch --no-browsers",
"start": "npm-run-all -p server watch",
"pretest": "npm-run-all lint clean build:css build:lang",
"pretest": "npm-run-all lint build",
"test": "karma start scripts/karma.conf.js",
"preversion": "npm test",
"version": "node scripts/version.js",
"watch": "npm-run-all -p watch:*",
"watch:js": "npm run build:js -- -w",
"watch:css": "npm run build:css -- -w",
"watch:js": "npm run build:js -- -w",
"prepublish": "not-in-install && npm run build || in-install",
"prepush": "npm run lint",
"precommit": "npm run docs:toc && git add README.md"
Expand All @@ -62,7 +62,8 @@
"vjsstandard": {
"ignore": [
"dist",
"docs"
"docs",
"test/dist"
]
},
"files": [
Expand Down Expand Up @@ -99,7 +100,6 @@
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-qunit": "^2.0.0",
"karma-rollup-preprocessor": "^6.0.0",
"karma-safari-launcher": "^1.0.0",
"mkdirp": "^0.5.1",
"npm-run-all": "^4.1.2",
Expand All @@ -108,7 +108,7 @@
"postcss-import": "^11.1.0",
"postcss-preset-env": "^5.1.0",
"qunit": "^2.5.1",
"rimraf": "^2.6.2",
"rimraf": "^2.6.1",
"rollup": "^0.60.1",
"rollup-plugin-babel": "^3.0.4",
"rollup-plugin-commonjs": "^9.1.3",
Expand All @@ -117,11 +117,15 @@
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-re": "^1.0.6",
"rollup-plugin-uglify": "^4.0.0",
"semver": "^5.4.1",
"semver": "^5.1.0",
"serve-static": "^1.13.2",
"sinon": "^5.1.0",
"uglify-es": "^3.3.9",
"videojs-languages": "^1.0.0",
"videojs-standard": "^6.0.0"
}
},
"browserslist": [
"defaults",
"ie 11"
]
}
37 changes: 3 additions & 34 deletions scripts/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
/* eslint-disable no-console */
const rollupPlugins = require('./primed-rollup-plugins');
const path = require('path');
const serveStatic = require('serve-static');
const path = require('path');
const serve = serveStatic(
path.join(__dirname, '..'),
{index: ['index.html', 'index.htm']}
);
const testGlobals = {
'qunit': 'QUnit',
'qunitjs': 'QUnit',
'sinon': 'sinon',
'video.js': 'videojs'
};
const testExternals = Object.keys(testGlobals).concat([
]);

const StaticMiddlewareFactory = function(config) {
console.log(`**** Dev server started at http://${config.listenAddress}:${config.port}/ *****`);
Expand Down Expand Up @@ -49,10 +40,7 @@ module.exports = function(config) {
'dist/videojs-vr.css',
'node_modules/sinon/pkg/sinon.js',
'node_modules/video.js/dist/video.js',
{included: false, pattern: 'src/**/*.js', watched: true},
// Make sure to disable Karma’s file watcher
// because the preprocessor will use its own.
{pattern: 'test/**/*.test.js', watched: false}
'test/dist/bundle.js'
],
customLaunchers: {
travisChrome: {
Expand All @@ -79,25 +67,6 @@ module.exports = function(config) {
colors: true,
autoWatch: false,
singleRun: true,
concurrency: Infinity,
preprocessors: {
'test/**/*.test.js': ['rollup']
},
rollupPreprocessor: {
output: {
format: 'iife',
name: 'videojsVrTest',
globals: testGlobals
},
external: testExternals,
plugins: [
rollupPlugins.multiEntry,
rollupPlugins.resolve,
rollupPlugins.json,
rollupPlugins.replace,
rollupPlugins.commonjs,
rollupPlugins.babel
]
}
concurrency: Infinity
});
};
10 changes: 5 additions & 5 deletions scripts/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
const banner = require('./banner').string;
const postcss = require('postcss');
const path = require('path');
const browsersList = require('./browserslist');
const pkg = require('../package.json');
const banner = `@name ${pkg.name} @version ${pkg.version} @license ${pkg.license}`;

/**
* by default there is no way to print that file was written
Expand Down Expand Up @@ -30,7 +30,7 @@ module.exports = function(context) {
// see https://preset-env.cssdb.org/features
// by default we use stage 3+
require('postcss-preset-env')({
browsers: browsersList,
browsers: pkg.browserslist,
stage: 3,
features: {
'custom-environment-variables': true,
Expand All @@ -42,13 +42,13 @@ module.exports = function(context) {
require('postcss-banner')({important: true, inline: true, banner}),

// add/remove vendor prefixes based on browser list
require('autoprefixer')(browsersList),
require('autoprefixer')(pkg.browserslist),

// minify
require('cssnano')({
safe: true,
preset: ['default', {
autoprefixer: browsersList
autoprefixer: pkg.browserslist
}]
}),

Expand Down
77 changes: 0 additions & 77 deletions scripts/primed-rollup-plugins.js

This file was deleted.

51 changes: 51 additions & 0 deletions scripts/rollup-replace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const replace = require('rollup-plugin-re');

// three modules to find-replace in
const modules = [
'VRControls',
'VREffect',
'OrbitControls',
'DeviceOrientationControls'
];

const globalReplace = function(str, pattern, replacement) {
return str.replace(new RegExp(pattern, 'g'), replacement);
};

module.exports = replace({
include: ['node_modules/three/examples/js/**'],
patterns: [
{transform(code, id) {
modules.forEach((m) => {
if (!(new RegExp(m)).test(id)) {
return;
}

// trun the global modifiction into an import and a local variable definition
code = code.replace(`THREE.${m} =`, `import * as THREE from 'three';\nvar ${m} =`);

// change references from the global modification to the local variable
code = globalReplace(code, `THREE.${m}`, m);

// export that local variable as default from this module
code += `\nexport default ${m};`;

// expose private functions so that users can manually use controls
// and we can add orientation controls
if (m === 'OrbitControls') {
code = globalReplace(code, 'function rotateLeft\\(', 'rotateLeft = function(');
code = globalReplace(code, 'function rotateUp\\(', 'rotateUp = function(');

code = globalReplace(code, 'rotateLeft', 'scope.rotateLeft');
code = globalReplace(code, 'rotateUp', 'scope.rotateUp');
// comment out the context menu prevent default line...
code = globalReplace(code,
"scope.domElement.addEventListener\\( 'contextmenu'",
"\/\/scope.domElement.addEventListener\\( 'contextmenu'"
);
}
});
return code;
}}
]
});
Loading

0 comments on commit 3a2d482

Please sign in to comment.