-
Notifications
You must be signed in to change notification settings - Fork 106
/
webpack.config.js
99 lines (97 loc) · 2.47 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
96
97
98
99
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)
require('babel-polyfill');
module.exports = {
devtool: 'source-map',
entry: [
'babel-polyfill',
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: /\.js$/,
loader: 'babel-loader',
options: {
configFile: path.resolve(__dirname, 'babel.config.js'),
},
},
{
test: /\.vue?$/,
loader: 'vue-loader',
options: {
loaders: {
js: {
loader: 'babel-loader',
options: {
configFile: path.resolve(__dirname, 'babel.config.js'),
},
},
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: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
overlay: true
}
}