Skip to content

Commit d11d5ce

Browse files
authored
Merge pull request #5 from sbolel/sbolel/chore/update
refactor: updates
2 parents b9efcc9 + 631ac6f commit d11d5ce

File tree

3 files changed

+67
-142
lines changed

3 files changed

+67
-142
lines changed

bin/create-webpack-config.js

+38-115
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,59 @@
1-
'use strict'
2-
3-
// const ExtractTextPlugin = require('extract-text-webpack-plugin')
4-
// const HtmlWebpackPlugin = require('html-webpack-plugin')
51
const path = require('path')
62
const webpack = require('webpack')
73
const pkg = require('../package.json')
84

5+
// paths
96
const buildPath = 'dist'
107
const publicPath = 'assets'
11-
const port = process.env.PORT || 3000
12-
const webpackPort = process.env.WEBPACK_PORT || 3001
138

14-
function createWebpackConfig (options) {
9+
// create configuration
10+
module.exports = function (options) {
1511
if (!options) { options = {} }
16-
// Sourcemaps
17-
const devtool = options.dev ? 'eval-source-map' : 'sourcemap'
18-
19-
const entry = path.join(__dirname, '..', 'src/index')
20-
21-
// Webpack dev-server
22-
// if (options.dev) {
23-
// entry = entry.concat(
24-
// 'webpack/hot/only-dev-server',
25-
// 'webpack-dev-server/client?http://localhost:' + webpackPort
26-
// )
27-
// }
28-
29-
const output = {
30-
path: path.resolve(__dirname, '..', buildPath),
31-
library: 'Pano',
32-
libraryTarget: 'umd',
33-
publicPath: '/dist/'
34-
}
3512

36-
var plugins = [
37-
new webpack.BannerPlugin('pano.js v' + pkg.version + ' | (c) Sinan Bolel & Prescott Prue', {
38-
raw: false, entryOnly: true
13+
const plugins = [
14+
new webpack.BannerPlugin({
15+
banner: `pano.js v${pkg.version} | (c) Sinan Bolel & Prescott Prue`,
16+
entryOnly: true, raw: false
3917
}),
40-
new webpack.NoErrorsPlugin(),
41-
// new ExtractTextPlugin('style.css', {allChunks: true}), //put all imported css into one bundled css file
42-
//
43-
// function () {
44-
// this.plugin('done', function (stats) {
45-
// fs.writeFileSync(
46-
// path.resolve(__dirname, '..', 'stats.json'),
47-
// JSON.stringify(stats.toJson())
48-
// )
49-
// })
50-
// }
18+
new webpack.NoEmitOnErrorsPlugin()
5119
]
5220

5321
if (!options.dev) {
54-
plugins = plugins.concat(
55-
[
56-
new webpack.optimize.UglifyJsPlugin({
57-
compress: {
58-
warnings: false
59-
},
60-
compressor: {
61-
screw_ie8: true,
62-
warnings: false
63-
}
64-
})
65-
]
66-
)
67-
}
68-
// Place the tags into an html file
69-
if (options.includeHtml) {
70-
plugins = plugins.concat(
71-
// new HtmlWebpackPlugin({
72-
// template: path.resolve(__dirname, '..', 'index.html'),
73-
// filename: 'index.html'
74-
// })
22+
plugins.push(
23+
new webpack.optimize.UglifyJsPlugin({
24+
compress: {
25+
warnings: false
26+
},
27+
compressor: {
28+
screw_ie8: true,
29+
warnings: false
30+
}
31+
})
7532
)
7633
}
7734

78-
const resolve = {
79-
alias: {
80-
assets: path.resolve(__dirname, '..', 'assets')
81-
},
82-
extensions: ['', '.js']
83-
}
84-
85-
const cssLoaders = [
86-
'css?root=..',
87-
'sass?outputStyle=expanded&'
88-
].join('!')
89-
90-
const loaders = [
91-
{
92-
exclude: /node_modules/,
93-
test: /\.js$/,
94-
loaders: ['babel']
95-
},
96-
// npm i --save-dev style-loader css-loader scss-loader
97-
// {
98-
// test: /\.(scss|css)$/,
99-
// loader: options.dev
100-
// ? 'style!' + cssLoaders
101-
// : ExtractTextPlugin.extract(cssLoaders)
102-
// },
103-
// npm i --save-dev url-loader file-loader
104-
// {
105-
// exclude: /node_modules/,
106-
// test: /\.(jpg|png|svg)$/,
107-
// loader: 'url?limit=8192'
108-
// },
109-
// npm i --save-dev url-loader file-loader
110-
// {
111-
// test: /\.json$/,
112-
// loader: 'json'
113-
// },
114-
// npm i --save-dev url-loader file-loader
115-
// {
116-
// test: /\.(otf|eot|svg|ttf|woff|woff2).*$/,
117-
// loader: 'url?limit=8192'
118-
// }
119-
]
12035
return {
12136
bail: !options.dev,
122-
devtool: devtool,
123-
entry: entry,
124-
output: output,
37+
devtool: options.dev ? 'eval-source-map' : 'sourcemap',
38+
entry: path.join(__dirname, '..', 'src/index'),
39+
module: {
40+
loaders: [{
41+
exclude: /node_modules/,
42+
loaders: ['babel-loader'],
43+
test: /\.js$/
44+
}]
45+
},
46+
output: {
47+
library: 'Pano',
48+
libraryTarget: 'umd',
49+
path: path.resolve(__dirname, '..', buildPath),
50+
publicPath: '/dist/'
51+
},
12552
plugins: plugins,
126-
resolve: resolve,
127-
module: { loaders: loaders },
128-
target: options.target,
129-
130-
port: port,
131-
webpackPort: webpackPort,
132-
buildPath: buildPath,
133-
publicPath: publicPath
53+
resolve: {
54+
alias: { assets: path.resolve(__dirname, '..', 'assets') },
55+
extensions: ['.js']
56+
},
57+
target: options.target
13458
}
13559
}
136-
module.exports = createWebpackConfig

package.json

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pano",
3-
"version": "1.1.1",
3+
"version": "2.0.0",
44
"description": "Easily add multiple 360-panoramic viewers to a page using Panolens.js",
55
"main": "dist/pano.js",
66
"jsnext:main": "src/pano.js",
@@ -12,7 +12,7 @@
1212
"test:cov": "babel-node $(npm bin)/isparta cover --report lcov ./node_modules/mocha/bin/_mocha -- ./test --recursive",
1313
"build:lib": "babel src --out-dir lib",
1414
"build:umd": "webpack src/index.js dist/pano.js --config webpack-development.config.js",
15-
"build:umd:min": "webpack -p src/index.js dist/pano.min.js --config webpack-production.config.js",
15+
"build:umd:min": "webpack src/index.js dist/pano.min.js --config webpack-production.config.js",
1616
"build": "npm run clean && npm run copy && npm run build:lib && npm run build:umd && npm run build:umd:min",
1717
"watch:umd": "npm run build:umd -- --stats --progress --colors --watch",
1818
"watch:lib": "npm run build:lib -- --stats --progress --colors --watch",
@@ -54,20 +54,21 @@
5454
"vr"
5555
],
5656
"dependencies": {
57-
"panolens.js": "^1.0.0"
57+
"panolens.js": "1.0.1-beta"
5858
},
5959
"devDependencies": {
60-
"babel-cli": "^6.6.5",
61-
"babel-core": "^6.7.2",
62-
"babel-loader": "^6.2.4",
63-
"babel-preset-es2015": "^6.5.0",
64-
"chai": "^3.5.0",
65-
"fs-extra": "^0.30.0",
66-
"isparta": "^4.0.0",
67-
"jsdom": "^9.2.1",
68-
"mocha": "^2.4.5",
69-
"rimraf": "^2.5.1",
70-
"standard": "^7.1.2",
71-
"webpack": "^1.12.14"
72-
}
60+
"babel-cli": "6.24.1",
61+
"babel-core": "6.24.1",
62+
"babel-loader": "7.0.0",
63+
"babel-preset-es2015": "6.24.1",
64+
"chai": "3.5.0",
65+
"fs-extra": "3.0.1",
66+
"isparta": "4.0.0",
67+
"jsdom": "10.1.0",
68+
"mocha": "3.3.0",
69+
"rimraf": "2.6.1",
70+
"standard": "10.0.2",
71+
"webpack": "2.5.1"
72+
},
73+
"peerDependencies": {}
7374
}

test/setup.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
var chai = global.chai = require('chai')
2-
var expect = global.expect = chai.expect
3-
var should = global.should = chai.should()
1+
const chai = global.chai = require('chai')
2+
const expect = global.expect = chai.expect
3+
const should = global.should = chai.should()
44

5-
// var Promise = require('es6-promise').Promise
5+
// const Promise = require('es6-promise').Promise
66
// global.Promise = Promise
77

8-
// var chaiAsPromised = require('chai-as-promised')
8+
// const chaiAsPromised = require('chai-as-promised')
99
// chai.use(chaiAsPromised)
1010

11-
var jsdom = require('jsdom')
12-
var doc = jsdom.jsdom('<html><body></body></html>')
13-
var win = doc.defaultView
14-
global.document = doc
15-
global.window = win
16-
global.navigator = win.navigator
11+
const jsdom = require("jsdom")
12+
const { JSDOM } = jsdom
13+
const dom = new JSDOM(`<html><body></body></html>`)
14+
15+
const { document } = dom.window
16+
global.document = dom.window.document
17+
// global.navigator = dom.window.navigator

0 commit comments

Comments
 (0)