OSDN Git Service

feat: support call transfer for the outer site
[bytom/Byone.git] / build / webpack.base.conf.js
1 const path = require("path");
2 const execa = require("execa");
3 const webpack = require("webpack");
4 const CopyWebpackPlugin = require("copy-webpack-plugin");
5 const WebpackAutoInject = require("webpack-auto-inject-version");
6 const ChromeReloadPlugin = require("wcer");
7 const { resolve, page, assetsPath } = require("./util");
8
9 var gitHash = execa.sync("git", ["rev-parse", "--short", "HEAD"]).stdout;
10 console.log("gitHash:", gitHash);
11 module.exports = {
12   entry: {
13     popup: resolve("src/popup"),
14     prompt: resolve("src/prompt"),
15     options: resolve("src/options"),
16     content: resolve("src/content"),
17     background: resolve("src/background"),
18     inject: resolve("src/content/inject")
19   },
20   output: {
21     path: resolve("dist"),
22     publicPath: "/",
23     filename: "js/[name].js",
24     chunkFilename: "js/[name].js"
25   },
26   module: {
27     rules: [
28       {
29         test: /\.css$/,
30         use: ["vue-style-loader", "css-loader"]
31       },
32       {
33         test: /\.scss$/,
34         use: ["vue-style-loader", "css-loader", "sass-loader"]
35       },
36       {
37         test: /\.sass$/,
38         use: ["vue-style-loader", "css-loader", "sass-loader?indentedSyntax"]
39       },
40       {
41         test: /\.vue$/,
42         loader: "vue-loader",
43         options: {
44           loaders: {
45             // Since sass-loader (weirdly) has SCSS as its default parse mode, we map
46             // the "scss" and "sass" values for the lang attribute to the right configs here.
47             // other preprocessors should work out of the box, no loader config like this necessary.
48             scss: ["vue-style-loader", "css-loader", "sass-loader"],
49             sass: [
50               "vue-style-loader",
51               "css-loader",
52               "sass-loader?indentedSyntax"
53             ]
54           }
55           // other vue-loader options go here
56         }
57       },
58       {
59         test: /\.js$/,
60         loader: "babel-loader",
61         exclude: /node_modules/
62       },
63       {
64         test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
65         loader: "url-loader",
66         options: {
67           limit: 10000,
68           name: assetsPath("img/[name].[hash:7].[ext]")
69         }
70       },
71       {
72         test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
73         loader: "url-loader",
74         options: {
75           limit: 10000,
76           name: assetsPath("media/[name].[hash:7].[ext]")
77         }
78       },
79       {
80         test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
81         loader: "url-loader",
82         options: {
83           limit: 10000,
84           name: assetsPath("fonts/[name].[hash:7].[ext]")
85         }
86       }
87     ]
88   },
89   resolve: {
90     alias: {
91       vue$: "vue/dist/vue.esm.js",
92       "@": resolve("src")
93     },
94     extensions: ["*", ".js", ".vue", ".json"]
95   },
96   plugins: [
97     page({
98       title: "popup title",
99       name: "popup",
100       chunks: ["popup"]
101     }),
102     page({
103       title: "options title",
104       name: "options",
105       chunks: ["options"]
106     }),
107     page({
108       title: "转账",
109       name: "prompt",
110       chunks: ["prompt"]
111     }),
112     new CopyWebpackPlugin([
113       {
114         from: resolve("static")
115       }
116     ]),
117     new ChromeReloadPlugin({
118       port: 23333,
119       manifest: resolve("src/manifest.js")
120     }),
121     new webpack.DefinePlugin({
122       "version.hash": JSON.stringify(gitHash)
123     }),
124     new WebpackAutoInject({
125       PACKAGE_JSON_PATH: './package.json',
126       components: {
127         AutoIncreaseVersion: true
128       },
129       componentsOptions: {
130         AutoIncreaseVersion: {
131           runInWatchMode: false // it will increase version with every single build!
132         }
133       }
134     })
135   ],
136   performance: {
137     hints: false
138   }
139 };