OSDN Git Service

fixed the error and updated the version to v2.0.1
[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.js'),
14     prompt: resolve('src/prompt.js'),
15     content: resolve('src/content.js'),
16     inject: resolve('src/inject.js'),
17     background: resolve('src/background.js')
18   },
19   output: {
20     path: resolve('dist'),
21     publicPath: '/',
22     filename: 'js/[name].js',
23     chunkFilename: 'js/[name].js'
24   },
25   module: {
26     rules: [
27       {
28         test: /\.css$/,
29         use: ['vue-style-loader', 'css-loader']
30       },
31       {
32         test: /\.scss$/,
33         use: ['vue-style-loader', 'css-loader', 'sass-loader']
34       },
35       {
36         test: /\.sass$/,
37         use: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax']
38       },
39       {
40         test: /\.vue$/,
41         loader: 'vue-loader',
42         options: {
43           loaders: {
44             // Since sass-loader (weirdly) has SCSS as its default parse mode, we map
45             // the "scss" and "sass" values for the lang attribute to the right configs here.
46             // other preprocessors should work out of the box, no loader config like this necessary.
47             scss: ['vue-style-loader', 'css-loader', 'sass-loader'],
48             sass: [
49               'vue-style-loader',
50               'css-loader',
51               'sass-loader?indentedSyntax'
52             ]
53           }
54           // other vue-loader options go here
55         }
56       },
57       {
58         test: /\.js$/,
59         loader: 'babel-loader',
60         exclude: /node_modules/
61       },
62       {
63         test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
64         loader: 'url-loader',
65         options: {
66           limit: 10000,
67           name: assetsPath('img/[name].[hash:7].[ext]')
68         }
69       },
70       {
71         test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
72         loader: 'url-loader',
73         options: {
74           limit: 10000,
75           name: assetsPath('media/[name].[hash:7].[ext]')
76         }
77       },
78       {
79         test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
80         loader: 'url-loader',
81         options: {
82           limit: 10000,
83           name: assetsPath('fonts/[name].[hash:7].[ext]')
84         }
85       }
86     ]
87   },
88   resolve: {
89     alias: {
90       vue$: 'vue/dist/vue.esm.js',
91       '@': path.resolve('src')
92     },
93     extensions: ['*', '.js', '.vue', '.json']
94   },
95   plugins: [
96     page({
97       title: 'popup title',
98       name: 'popup',
99       chunks: ['popup']
100     }),
101     page({
102       title: 'options title',
103       name: 'options',
104       chunks: ['options']
105     }),
106     page({
107       title: 'Byone notification',
108       name: 'prompt',
109       chunks: ['prompt']
110     }),
111     new CopyWebpackPlugin([
112       {
113         from: resolve('static')
114       }
115     ]),
116     new ChromeReloadPlugin({
117       port: 23333,
118       manifest: resolve('src/manifest.js')
119     }),
120     new webpack.DefinePlugin({
121       'version.hash': JSON.stringify(gitHash)
122     }),
123     new WebpackAutoInject({
124       PACKAGE_JSON_PATH: './package.json',
125       components: {
126         AutoIncreaseVersion: false
127       }
128     })
129   ],
130   performance: {
131     hints: false
132   }
133 }