Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.
Merged
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
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