-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
executable file
·109 lines (101 loc) · 2.49 KB
/
webpack.common.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// webpack.config.js
module.exports = {
/* Main entry point of the app. Files listed will be "compiled" and files used by listed files will also be compiled */
entry: ['@/src/app.js', '@/styles/main.scss'],
output: {
path: path.resolve(__dirname, 'build/'), // Use [hash] in both path and publicPath for produktion environment
publicPath: '/' // The URL-path
},
watchOptions: {
// Watching the node_modules-folder can be slow, resource hogging and very unnecessary
ignored: /node_modules/
},
resolve: {
alias: {
"vue$": "vue/dist/vue.esm.js",
'@': path.resolve(__dirname),
}
},
module: {
rules: [{
test: /\.html$/,
use: [{
loader: 'html-loader',
options: {
minimize: true,
},
}, ]
}, {
test: /\.vue$/,
loader: 'vue-loader'
},
// this will apply to both plain `.js` files
// AND `<script>` blocks in `.vue` files
{
test: /\.js$/,
loader: 'babel-loader'
},
// this will apply to both plain `.css` files
// AND `<style>` blocks in `.vue` files
{
test: /\.css$/,
use: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
// enable CSS Modules
modules: true,
// customize generated class names
localIdentName: '[local]_[hash:base64:8]'
}
}
]
},
{
test: /\.(sa|sc)ss$/i,
use: [
// Creates `style` nodes from JS strings
MiniCssExtractPlugin.loader,
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader'
},
],
},
plugins: [
// Generate HTML
new HtmlWebpackPlugin({
template: 'html/index.html',
// filename: 'index.html',
// title: 'tjobba',
}),
new VueLoaderPlugin(),
new CopyPlugin([{
from: 'images/*',
to: '.'
},{
from: 'images/gallery/*',
to: '.'
}]),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
// filename: devMode ? '[name].css' : '[name].[contenthash].css',
// chunkFilename: devMode ? '[id].css' : '[id].[contenthash].css',
filename: '[name].[contenthash].css',
chunkFilename: '[id].[contenthash].css',
}),
],
};