Skip to content
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
Build the library using Webpack and refactor some libraries
  • Loading branch information
elchininet committed May 11, 2020
commit 9f9b7c6a819680c3913f5f038810f9291ddf380d
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"scripts": {
"test": "jest --clearCache && jest --verbose",
"lint": "eslint src/**/*.ts",
"build": "del ./dist && tsc && tscpaths -p tsconfig.json -s ./src -o ./dist",
"build": "webpack && tscpaths -p tsconfig.json -s ./src -o ./dist",
"prepare": "npm run build",
"prepublishOnly": "npm run lint && npm run test",
"version": "git add .",
Expand All @@ -40,23 +40,23 @@
"@types/eslint": "^6.8.0",
"@types/facepaint": "^1.2.1",
"@types/jest": "^25.2.1",
"@types/node": "^13.11.1",
"@types/node": "^13.13.5",
"@types/rtlcss": "^2.4.0",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"coveralls": "^3.0.11",
"@typescript-eslint/eslint-plugin": "^2.32.0",
"@typescript-eslint/parser": "^2.32.0",
"clean-webpack-plugin": "^3.0.0",
"coveralls": "^3.1.0",
"del-cli": "^3.0.0",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-unicorn": "^18.0.1",
"eslint-utils": "^2.0.0",
"eslint": "^7.0.0",
"eslint-plugin-jest": "^23.10.0",
"jest": "^25.3.0",
"postcss": "^7.0.27",
"ts-jest": "^25.3.1",
"tsconfig-paths": "^3.9.0",
"postcss": "^7.0.30",
"ts-jest": "^25.5.1",
"ts-loader": "^7.0.4",
"tscpaths": "^0.0.9",
"typecript": "^0.0.1-security",
"typescript": "^3.8.3"
"typescript": "^3.8.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"peerDependencies": {
"postcss": "^7.0.0"
Expand Down
37 changes: 37 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const tsconfig = require('./tsconfig');

const { compilerOptions: { baseUrl, paths } } = tsconfig;
const aliasReg = (str) => str.replace(/^(.*)\/\*$/, '$1');

module.exports = {
mode: 'production',
entry: './src/index.ts',
output: {
filename: 'index.js',
path: path.resolve(__dirname, './dist'),
libraryTarget: 'commonjs'
},
resolve: {
extensions: ['.js', '.ts', '.json'],
alias: Object.keys(paths).reduce(
(obj, a) => (obj[aliasReg(a)] = path.resolve(__dirname, aliasReg(`${baseUrl}/${paths[a]}`)), obj),
{}
)
},
module: {
rules: [
{
test: /\.ts?$/,
loader: 'ts-loader'
}
]
},
externals: {
'postcss': 'commonjs postcss'
},
plugins: [
new CleanWebpackPlugin()
]
};
Loading