Skip to content

Commit

Permalink
config webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
slotDumpling committed Aug 17, 2023
1 parent ee28a1f commit 12ff597
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 67 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm ci

- name: Patch package
run: npm run patch

- name: Build
run: npm run build

- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "draft-pad",
"version": "0.2.0",
"version": "0.2.1",
"private": false,
"main": "dist/index.js",
"types": "dist/src/index.d.ts",
"types": "dist/index.d.ts",
"author": "slot-dumpling",
"dependencies": {
"@react-hook/size": "^2.1.2",
Expand All @@ -18,7 +18,7 @@
"scripts": {
"build": "webpack",
"dev": "webpack --config webpack.dev.js",
"postinstall": "patch-package"
"patch": "patch-package"
},
"devDependencies": {
"@types/heap": "^0.2.31",
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"declaration": true,
"declarationMap": true
}
"declaration": true
},
"exclude": ["webpack.*", "dist/*"]
}
14 changes: 4 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
// const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");

module.exports = {
mode: "production",
Expand All @@ -20,14 +19,7 @@ module.exports = {
},
{
test: /\.(png|jpg|gif|svg)$/i,
use: [
{
loader: "url-loader",
options: {
limit: true,
},
},
],
use: "url-loader",
},
{
test: /\.css$/,
Expand All @@ -41,5 +33,7 @@ module.exports = {
externals: {
react: "react",
"react-dom": "react-dom",
immutable: "immutable",
},
// plugins: [new BundleAnalyzerPlugin()],
};
53 changes: 4 additions & 49 deletions webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,6 @@
var path = require("path");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const config = require("./webpack.config");
config.mode = "development";
config.watch = true;

module.exports = {
mode: "development",
entry: "./src/index.tsx",
output: {
path: path.resolve("dist"),
filename: "index.js",
libraryTarget: "commonjs2",
},
devtool: "source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: "ts-loader",
options: {
compilerOptions: { module: "ESNext", target: "ESNext" },
},
},
exclude: /node_modules/,
},
{
test: /\.(png|jpg|gif|svg)$/i,
use: [
{
loader: "url-loader",
options: {
limit: true,
},
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
externals: {
react: "react",
"react-dom": "react-dom",
},
plugins: [new BundleAnalyzerPlugin()],
watch: true,
};
module.exports = config;

0 comments on commit 12ff597

Please sign in to comment.