浏览代码

chore: fix CommonsChunkPlugin usage

Gerald 8 年之前
父节点
当前提交
b6b3bc452d
共有 4 个文件被更改,包括 22 次插入34 次删除
  1. 10 16
      scripts/webpack.conf.js
  2. 0 8
      src/background/index.html
  3. 0 10
      src/popup/index.html
  4. 12 0
      src/public/index.html

+ 10 - 16
scripts/webpack.conf.js

@@ -20,34 +20,28 @@ targets.push(merge(base, {
   entry,
   plugins: [
     new webpack.optimize.CommonsChunkPlugin({
-      name: 'browser',
-      chunks: Object.keys(entry),
+      name: 'common',
+      chunks: Object.keys(entry).filter(name => name !== 'injected'),
+      minChunks: (m, c) => c >= 2,
     }),
     new webpack.optimize.CommonsChunkPlugin({
-      name: 'vendor',
-      chunks: Object.keys(entry).filter(key => key !== 'injected'),
-      minChunks: 2,
+      name: 'browser',
+      chunks: ['common', 'injected'],
+      minChunks: (m, c) => c >= 2,
     }),
     new HtmlWebpackPlugin({
       filename: 'background/index.html',
-      template: 'src/background/index.html',
-      inject: true,
-      chunks: ['vendor', 'browser', 'background/app'],
-      chunksSortMode: 'dependency'
+      chunks: ['browser', 'common', 'background/app'],
     }),
     new HtmlWebpackPlugin({
       filename: 'options/index.html',
       template: 'src/options/index.html',
-      inject: true,
-      chunks: ['vendor', 'browser', 'options/app'],
-      chunksSortMode: 'dependency'
+      chunks: ['browser', 'common', 'options/app'],
     }),
     new HtmlWebpackPlugin({
       filename: 'popup/index.html',
-      template: 'src/popup/index.html',
-      inject: true,
-      chunks: ['vendor', 'browser', 'popup/app'],
-      chunksSortMode: 'dependency'
+      template: 'src/public/index.html',
+      chunks: ['browser', 'common', 'popup/app'],
     }),
     // new FriendlyErrorsPlugin(),
     !IS_DEV && new ExtractTextPlugin('[name].css'),

+ 0 - 8
src/background/index.html

@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<title>ViolentMonkey</title>
-</head>
-<body></body>
-</html>

+ 0 - 10
src/popup/index.html

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<title>Popup Menu - Violentmonkey</title>
-</head>
-<body>
-<div id="app"></div>
-</body>
-</html>

+ 12 - 0
src/public/index.html

@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title></title>
+<link rel="icon" type="image/png" href="/public/images/icon32.png" sizes="32x32">
+<link rel="icon" type="image/png" href="/public/images/icon16.png" sizes="16x16">
+</head>
+<body>
+<div id="app"></div>
+</body>
+</html>