forked from TIGERB/easy-php
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
96 lines (89 loc) · 2.29 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
var webpack = require('webpack');
var path = require('path');
var webpackDevServer = require('webpack-dev-server');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');// separate css
var CleanPlugin = require('clean-webpack-plugin');// clean bulid file
var webpackConfig = module.exports = {};// init object
var production = process.env.NODE_ENV === 'production';// production environment
var domain = process.env.DOMAIN; // your domain process.env.domain
// input
webpackConfig.entry = {
app:[
// main
'./frontend/app.js',
],
};
webpackConfig.output = {
path: path.resolve(__dirname, './public/dist'),
publicPath: domain+'/dist/',
filename: production? '[name].[hash].js': '[name].js'
};// output
//loader
webpackConfig.module = {
rules : [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader",
publicPath: path.resolve(__dirname, 'dist')
})
},
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader'
}
]
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(eot(|\?v=.*)|woff(|\?v=.*)|woff2(|\?v=.*)|ttf(|\?v=.*)|svg(|\?v=.*))$/,
use: [
{
loader: 'file-loader'
}
]
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader'
}
]
},
]
};
webpackConfig.plugins = [
// make index.html
new HtmlWebpackPlugin({
title: 'easy-vue',
filename: path.resolve(__dirname, './public') + '/index.html',
template: './frontend/index.template.html'
}),
// separate css file
new ExtractTextPlugin({
filename: production? 'app.[hash].css': 'app.css',
// disable: false,
// allChunks: true
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
})
];
/* production plugins need */
if (production) {
webpackConfig.plugins.concat([
// clean build file
new CleanPlugin('dist')
]);
}