-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
125 lines (124 loc) · 2.84 KB
/
Copy pathwebpack.config.js
File metadata and controls
125 lines (124 loc) · 2.84 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const TerserPlugin = require("terser-webpack-plugin")
const ESLintPlugin = require('eslint-webpack-plugin')
const PrettierPlugin = require("prettier-webpack-plugin")
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
entry: {
main: './main.js',
vuecore: {
import: './plugins/vuecore.js',
library: {
// all options under `output.library` can be used here
name: 'vuecore',
type: 'umd',
umdNamedDefine: true,
},
},
css: './sass/main.sass'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
// library: 'vuecore',
// libraryTarget: 'umd'
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 8080,
publicPath: 'http://localhost:8080/',
historyApiFallback: true
},
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader'
},
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: [
process.env.NODE_ENV !== 'production' ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
// Enable CSS Module
modules: {
mode: 'local',
localIdentName: "[hash:base64:5]"
}
}
}
]
},
{
test: /\.s[a|c]ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
["autoprefixer"]
],
},
}
},
{
loader: 'sass-loader',
options: {
// sass-loader version >= 8
sassOptions: {
indentedSyntax: true
}
}
}
]
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[contenthash].[ext]',
outputPath: 'img',
esModule: false,
},
},
],
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
chunks: ['main']
}),
new VueLoaderPlugin(),
new ESLintPlugin(),
new PrettierPlugin(),
new MiniCssExtractPlugin({
filename: 'main.css'
})
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin()
]
}
}