-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
executable file
·109 lines (105 loc) · 3.12 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
100
101
102
103
104
105
106
107
108
109
const path = require('path');
const webpack = require('webpack');
/*
* Webpack Plugins
*/
const ManifestPlugin = require('webpack-manifest-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
// take debug mode from the environment
const debug = (process.env.NODE_ENV !== 'production');
// Development asset host (webpack dev server)
const publicHost = debug ? 'http://localhost:2992' : '';
module.exports = {
// configuration
context: __dirname,
entry: {
app_js: path.join(__dirname, 'src', 'app')
},
node: {
fs: 'empty'
},
output: {
path: path.join(__dirname, 'app', 'static', 'build'),
publicPath: `${publicHost}/static/build/`,
filename: '[name].[hash].js',
chunkFilename: '[id].[hash].js',
},
resolve: {
extensions: ['.ts', '.js', '.jsx'],
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devtool: 'source-map',
devServer: {
headers: {'Access-Control-Allow-Origin': '*'},
},
module: {
rules: [
{test: /\.html$/, loader: 'raw-loader'},
{
test: /\.s?[ac]ss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.(ttf|eot|svg|png|jpe?g|gif|ico|woff|manifest)(\?.*)?$/i,
loader: 'file-loader',
options: {
context: path.join(__dirname, 'src'),
name: '[path][name].[hash].[ext]',
}
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {presets: ['env'], cacheDirectory: true}
},
{
test: /\.vue$/,
use: [
{ loader: 'vue-loader' },
{
loader: 'vue-svg-inline-loader',
options: {
svgo: {
plugins: [
{
prefixIds: true
}
]
}
}
}
]
},
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules|\.d\.ts$/,
options: {
appendTsSuffixTo: [/\.vue$/],
}
},
{
test: /\.d\.ts$/,
loader: 'ignore-loader'
},
],
},
plugins: [
new ManifestPlugin({fileName: path.join(__dirname, 'app', 'webpack', 'manifest.json'), writeToFileEmit: debug}),
new VueLoaderPlugin()
].concat(debug ? [] : [
// production webpack plugins go here
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
}
}),
]),
};