Browse Source

:art: add folder

Van 6 năm trước cách đây
mục cha
commit
fc7b9fcff5
4 tập tin đã thay đổi với 17 bổ sung28 xóa
  1. 2 2
      demo/demo.js
  2. 2 2
      demo/index.html
  3. 3 4
      package.json
  4. 10 20
      webpack.config.js

+ 2 - 2
demo/demo.js

@@ -1,5 +1,5 @@
-// import Vditor from '../src/index'
-import Vditor from '../dist/index.min'
+import Vditor from '../src/index'
+// import Vditor from '../dist/vditor/index.min'
 
 const vditor = new Vditor('vditor', {
   height: 200,

+ 2 - 2
demo/index.html

@@ -39,7 +39,7 @@
     <link href="dist/demo.css" rel="stylesheet">
     <script src="dist/demo.js" defer></script>
     <!-- 静态文件引入文件 -->
-    <!--<link href="../dist/index.classic.css" rel="stylesheet">-->
+    <!--<link href="../dist/vditor/index.classic.css" rel="stylesheet">-->
 
 </head>
 <body>
@@ -48,7 +48,7 @@
 <h2>自定义编辑器</h2>
 <div id="vditor"></div>
 <!-- 静态文件引入文件 -->
-<!--<script src="../dist/index.min.js"></script>-->
+<!--<script src="../dist/vditor/index.min.js"></script>-->
 <!--<script src="demo.js"></script>-->
 </body>
 </html>

+ 3 - 4
package.json

@@ -4,9 +4,9 @@
   "description": "A markdown editor written in TypeScript",
   "author": " Vanessa <[email protected]> (http://vanessa.b3log.org)",
   "homepage": "https://hacpai.com/cr",
-  "main": "dist/index.min.js",
+  "main": "dist/vditor/index.min.js",
   "files": [
-    "dist/*"
+    "dist/vditor/*"
   ],
   "dependencies": {
     "recordrtc": "^5.5.3",
@@ -44,8 +44,7 @@
     "url": "https://github.com/b3log/vditor/issues"
   },
   "scripts": {
-    "build": "webpack --env.production",
-    "dev": "webpack",
+    "build": "webpack",
     "demo": "webpack --config webpack.demo.js",
     "start": "webpack-dev-server --config webpack.start.js"
   },

+ 10 - 20
webpack.config.js

@@ -42,15 +42,14 @@ SOFTWARE.
   entryOnly: true,
 })
 
-const baseConfig = [
+module.exports = [
   {
-    mode: 'development',
-    watch: true,
+    mode: 'production',
     output: {
       filename: '[name].js',
-      path: path.resolve(__dirname, 'dist'),
+      path: path.resolve(__dirname, 'dist/vditor'),
       chunkFilename: '[name].bundle.js',
-      publicPath: '/dist/',
+      publicPath: '/dist/vditor/',
       libraryTarget: 'umd',
       library: 'Vditor',
       libraryExport: 'default',
@@ -115,7 +114,7 @@ const baseConfig = [
       ],
     },
     plugins: [
-      new CleanWebpackPlugin(['./dist']),
+      new CleanWebpackPlugin(['./dist/vditor']),
       new webpack.DefinePlugin({
         VDITOR_VERSION: JSON.stringify(pkg.version),
       }),
@@ -124,8 +123,8 @@ const baseConfig = [
   }, {
     mode: 'production',
     entry: {
-      'index.classic': './src/assets/scss/classic.scss',
-      'index.dark': './src/assets/scss/dark.scss',
+      'vditor/index.classic': './src/assets/scss/classic.scss',
+      'vditor/index.dark': './src/assets/scss/dark.scss',
     },
     resolve: {
       extensions: ['.scss'],
@@ -170,17 +169,8 @@ const baseConfig = [
         filename: '[name].css',
       }),
       new WebpackOnBuildPlugin(() => {
-        fs.unlinkSync('./dist/index.classic.js')
-        fs.unlinkSync('./dist/index.dark.js')
+        fs.unlinkSync('./dist/vditor/index.classic.js')
+        fs.unlinkSync('./dist/vditor/index.dark.js')
       }),
     ],
-  }]
-
-module.exports = env => {
-  if (env && env.production) {
-    baseConfig[0].mode = 'production'
-    baseConfig[0].watch = false
-    return baseConfig
-  }
-  return baseConfig
-}
+  }]