-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.parts.js
91 lines (88 loc) · 2.37 KB
/
webpack.parts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
analyzeBundles: ({ port }) => ({
plugins: [new BundleAnalyzerPlugin({
analyzerPort: port
})]
}),
devServer: ({ port }) => ({
devtool: 'eval-cheap-module-source-map',
devServer: {
compress: false,
port,
contentBase: './dist',
quiet: false,
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp'
}
}
}),
baseConfig: ({ isDev }) => ({
output: {
filename: '[name].[contenthash].js',
path: path.join(__dirname, 'dist'),
publicPath: isDev ? '/' : '/life.js/'
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({ favicon: './app/assets/favicon.ico', template: './app/index.html' })
],
resolve: {
extensions: ['.js'],
modules: [
'app',
'node_modules'
]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{ test: /\.worker\.js$/, use: { loader: 'worker-loader' } },
// { test: /\.png$/, use: 'url-loader?limit=100000' },
// { test: /\.jpg$/, use: 'file-loader' },
{ test: /\.ttf$/, use: 'file-loader' },
{ test: /\.glsl$/, use: 'raw-loader' },
{
test: /favicon\.ico$/,
use: 'file-loader?name=[name].[ext]'
}
]
}
}),
vuejs: ({ isDev }) => ({
resolve: {
extensions: ['.vue'],
alias: {
vue: isDev ? 'vue/dist/vue.runtime.js' : 'vue/dist/vue.runtime.min.js'
}
},
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css'
})
],
module: {
rules: [
{
test: /\.css$/,
use: [
isDev ? 'style-loader' : MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { sourceMap: isDev } }
]
},
{ test: /\.vue$/, use: 'vue-loader' }
]
}
})
}