-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
95 lines (93 loc) · 2.45 KB
/
webpack.config.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
"use strict"
const webpack = require('webpack')
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: {
index:'./src/views/home/index'
},
output: {
path: path.resolve(__dirname,'./dist/'),
filename:'js/[name].js',
// publicPath: '/dist/',
chunkFilename: 'js/[id].js',
},
module: {
rules: [
{
test: /\.scss$/,
exclude: /node_modules/,
include:path.resolve(__dirname,'./src'),
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [{
loader: 'css-loader',
options: {
localIdentName: '_[hash:base64:6]'
}
}, {
loader: 'sass-loader'
}],
})
},
{
test: /\.js$/,
exclude: /node_modules/,
include: path.resolve(__dirname, './src'),
use: [{
loader: 'babel-loader',
options: {
presets: ['env','es2015'],
cacheDirectory: true
}
}]
},
{
test:/\.vue$/,
exclude: /node_modules/,
include: path.resolve(__dirname, './src'),
use:[{
loader:'vue-loader',
options: {
cssModules: {
// localIdentName: '[path][name]-[local]-[hash:base64:5]',
localIdentName: '[name]_[hash:base64:5]',
camelCase: true
},
loaders: {
es6: 'babel-loader?presets=es2015',
docs: ExtractTextPlugin.extract('raw-loader'),
scss: 'vue-style-loader!css-loader!sass-loader', // <style lang="scss">
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax' // <style lang="sass">
}
}
}]
}
]
},
resolve: {
extensions:['.js','.vue','.scss','.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
plugins: [
new ExtractTextPlugin('md/docs.md'),
new HtmlWebpackPlugin({
filename:path.resolve(__dirname,'./dist/index.html'),
template:path.resolve(__dirname,'./src/views/home/index.html'),
inject:'body'
})
],
devtool: 'cheap-module-source-map',
devServer: {
contentBase:path.join(__dirname,'dist/'),
port: 4000,
inline: true,
hot: false,
// open:true,
// noInfo:true,
// compress: true,
}
}