Skip to content

Commit b2d148e

Browse files
author
nezanuha
committed
add style entry for CSS in package.json
1 parent 10c8930 commit b2d148e

File tree

2 files changed

+30
-32
lines changed

2 files changed

+30
-32
lines changed

package.json

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "markdown-text-editor",
3-
"version": "0.0.16-beta.1",
3+
"version": "0.0.18-beta.1",
44
"description": "A powerful, easy-to-use Markdown editor with a real-time preview, syntax highlighting. Ideal for developers, writers, and content creators who need a seamless, interactive writing experience with full Markdown support.",
5-
"main": "./src/plugins/markdown/editor.js",
5+
"main": "./dist/markdown-text-editor.js",
6+
"style": "./dist/markdown-text-editor.css",
67
"files": [
78
"dist/**/*",
89
"src/**/*"
@@ -12,36 +13,29 @@
1213
"url": "https://github.com/nezanuha/markdown-text-editor"
1314
},
1415
"scripts": {
15-
"build": "webpack --mode=production",
16+
"clean": "rm -rf dist",
17+
"build": "npm run clean && webpack --mode=production",
18+
"prepublishOnly": "npm run build",
1619
"dev": "webpack --watch --mode=development"
1720
},
1821
"publishConfig": {
1922
"registry": "https://registry.npmjs.org/"
2023
},
2124
"keywords": [
2225
"markdown-text-editor",
23-
"markdown-text",
24-
"mde",
25-
"text-editor",
26-
"simple mde",
2726
"markdown",
27+
"text-editor",
2828
"editor",
2929
"live preview",
3030
"syntax highlighting",
31-
"react",
32-
"web app",
3331
"developer tools",
3432
"content creation",
35-
"WYSIWYG",
3633
"plugin",
37-
"open source",
38-
"markdown",
39-
"markdown editor",
40-
"simple markdown"
34+
"open source"
4135
],
4236
"author": "Nezanuha",
4337
"license": "MIT",
44-
"homepage": "",
38+
"homepage": "https://github.com/nezanuha/markdown-text-editor",
4539
"bugs": {
4640
"url": "https://github.com/nezanuha/markdown-text-editor/issues"
4741
},

webpack.config.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
33
const TerserPlugin = require('terser-webpack-plugin');
44

55
module.exports = (env, argv) => {
6-
const isProd = process.env.NODE_ENV === 'production';
6+
const isProd = argv.mode === 'production';
77
return {
8-
mode: isProd ? 'production' : 'development', // Set to 'production' for minified output
8+
mode: isProd ? 'production' : 'development',
99
stats: 'minimal',
1010
entry: {
1111
index: './src/plugins/index.js',
@@ -15,25 +15,28 @@ module.exports = (env, argv) => {
1515
extensions: ['.ts', '.js'],
1616
},
1717
output: {
18-
filename: '[name].js', // Output file name
19-
path: path.resolve(__dirname, 'dist'), // Output directory
20-
library: '[name]', // Name of the library
21-
libraryTarget: 'umd', // Universal Module Definition
22-
libraryExport: 'default', // Use default export
23-
globalObject: 'this', // Ensures compatibility
18+
filename: '[name].js',
19+
path: path.resolve(__dirname, 'dist'),
20+
library: {
21+
name: '[name]',
22+
type: 'umd',
23+
export: 'default',
24+
},
25+
globalObject: 'typeof self !== "undefined" ? self : this',
26+
clean: true, // Ensures output directory is cleaned before each build
2427
},
2528
module: {
2629
rules: [
2730
{
28-
test: /\.css$/, // Handle CSS files
31+
test: /\.css$/,
2932
use: [
30-
'style-loader', // Extract CSS into separate files
31-
'css-loader', // Translates CSS into CommonJS
32-
'postcss-loader', // Processes CSS with PostCSS
33+
MiniCssExtractPlugin.loader,
34+
'css-loader',
35+
'postcss-loader',
3336
],
3437
},
3538
{
36-
test: /\.m?js$/, // Handle JavaScript files
39+
test: /\.m?js$/,
3740
exclude: /node_modules/,
3841
use: {
3942
loader: 'babel-loader',
@@ -46,16 +49,17 @@ module.exports = (env, argv) => {
4649
},
4750
plugins: [
4851
new MiniCssExtractPlugin({
49-
filename: 'styles.css', // Output CSS filename
52+
filename: '[name].css',
5053
}),
5154
],
5255
optimization: {
53-
minimize: true,
56+
minimize: isProd,
5457
minimizer: [
5558
new TerserPlugin({
5659
extractComments: false,
5760
}),
5861
],
59-
}
62+
},
63+
devtool: isProd ? 'source-map' : 'eval-source-map',
6064
};
61-
};
65+
};

0 commit comments

Comments
 (0)