Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Improved build output (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinvdvleuten authored Nov 1, 2017
1 parent 373a04c commit 0c16d34
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@
"url": "https://github.com/robinvdvleuten/vuex-persistedstate/issues"
},
"main": "dist/vuex-persistedstate.js",
"browser": "dist/vuex-persistedstate.umd.js",
"jsnext:main": "src/plugin.js",
"files": [
"dist/vuex-persistedstate.js",
"dist/vuex-persistedstate.min.js",
"dist",
"src",
"LICENSE",
"README.md"
],
"scripts": {
"build": "rollup -c --environment NODE_ENV:production && uglifyjs dist/vuex-persistedstate.js --comments -o dist/vuex-persistedstate.min.js",
"test": "npm run build && jest --env=jsdom",
"build": "mkdir -p dist && npm run -s build:cjs && npm run -s build:umd",
"build:cjs": "rollup -c -f cjs | uglifyjs -cm -o $npm_package_main",
"build:umd": "rollup -c -n $npm_package_name -f umd | uglifyjs -cm -o $npm_package_browser",
"precommit": "npm run build && lint-staged",
"prepublish": "npm run build"
"prepublish": "npm run build",
"test": "jest --env=jsdom"
},
"lint-staged": {
"src/**/*.js": [
Expand Down
35 changes: 12 additions & 23 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
const buble = require('rollup-plugin-buble')
const pkg = require('./package.json')
import buble from 'rollup-plugin-buble';
import fs from 'fs';

const banner =
`/**
* @license
*
* vuex-persistedstate v${pkg.version}
*
* (c) ${new Date().getFullYear()} Robin van der Vleuten <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/`
const pkg = JSON.parse(fs.readFileSync('./package.json'));

module.exports = {
entry: 'src/plugin.js',
moduleName: 'createPersistedState',
dest: pkg.main,
useStrict: false,
format: 'umd',
globals: {
export default {
entry: 'src/plugin.js',
useStrict: false,
sourceMap: false,
plugins: [
buble()
],
globals: {
'lodash.merge': 'merge'
},
external: ['lodash.merge'],
plugins: [buble()],
banner
}
};
4 changes: 2 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const defaultReducer = (state, paths) =>

const canWriteStorage = storage => {
try {
storage.setItem('_canWriteToStorage', 1);
storage.removeItem('_canWriteToStorage');
storage.setItem('@@', 1);
storage.removeItem('@@');
return true;
} catch (e) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from 'vue';
import Vuex, { Store } from 'vuex';
import Storage from 'dom-storage';
import createPersistedState from '../dist/vuex-persistedstate';
import createPersistedState from './plugin';

Vue.use(Vuex);

Expand Down

0 comments on commit 0c16d34

Please sign in to comment.