forked from cadence-workflow/cadence-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
80 lines (79 loc) · 1.99 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
const
path = require('path'),
webpack = require('webpack'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
extractStylus = 'css-loader?sourceMap!stylus-loader',
development = !['production', 'ci'].includes(process.env.NODE_ENV)
module.exports = {
devtool: 'source-map',
entry: [
path.join(__dirname, process.env.TEST_RUN ? 'client/test/index' : 'client/main')
].filter(x => x),
output: {
path: path.join(__dirname, 'dist'),
filename: 'cadence.[hash].js',
publicPath: '/'
},
plugins: [
!development && new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new ExtractTextPlugin({ filename: development ? 'cadence.css' : 'cadence.[hash].css', allChunks: true }),
new HtmlWebpackPlugin({
title: 'Cadence',
filename: 'index.html',
favicon: 'favicon.ico',
inject: false,
template: require('html-webpack-template'),
lang: 'en-US',
scripts: (process.env.CADENCE_EXTERNAL_SCRIPTS || '').split(',').filter(x => x)
})
].filter(x => x),
module: {
rules: [{
test: /\.vue?$/,
loader: 'vue-loader',
options: {
loaders: {
stylus: ExtractTextPlugin.extract({
use: extractStylus,
fallback: 'vue-style-loader'
}),
}
}
}, {
test: /\.svg$/,
use: [{
loader: 'html-loader',
options: {
minimize: true
}
}]
}, {
test: /\.(png|jpg|gif)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}, {
test: /\.styl$/,
use: ExtractTextPlugin.extract({ use: extractStylus, fallback: 'raw-loader' }),
include: path.join(__dirname, 'src')
}]
},
resolve: {
extensions: ['.js', '.vue']
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
historyApiFallback: true,
overlay: true
}
}