- 项目地址:码云
- .babelrc
{
"presets": [
"@babel/preset-env"
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"corejs": 3,
"helpers": true,
"regenerator": true,
"useESModules": false
}
]
]
}
- .gitignore
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.zip
- package.json
{
"name": "library",
"version": "1.0.0",
"description": "",
"main": "./dist/library.js",
"scripts": {
"build": "webpack"
},
"author": "Xavier",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"babel-loader": "^8.2.2",
"clean-webpack-plugin": "^3.0.0",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12"
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"@babel/runtime-corejs3": "^7.12.5"
}
}
const path = require('path');
const {
CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
mode: 'production',
devtool: 'cheap-module-source-map',
entry: {
index: './src/index.js'
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'storageObj.js',
library: 'storageObj',
libraryTarget: 'umd'
},
plugins: [
new CleanWebpackPlugin()
]
}
import {
hl } from './public/HappyLocalStorage.js';
import {
hc } from './public/HappyCookie.js';
export {
hl, hc
}
- 项目结构图