-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.config.js
95 lines (94 loc) · 3.34 KB
/
webpack.prod.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
var path = require('path');
var webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin');
var config = {
entry: {
index: [path.resolve(__dirname, 'source/index.js')]
},
output: {
path: path.resolve(__dirname, 'dist/bundle/'),
publicPath: "./bundle/",
filename: "[name].bundle.js",
chunkFilename: "[id].chunk.js"
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
}
},
module: {
loaders: [
{
test: /\.(js)$/,
loader: 'babel-loader',
exclude: /(semantic.js)|(node_modules)/,
query: {
// presets: ['babel-preset-env']
presets: [
["env", {
"targets": {
"browsers": ["ie >= 9"]
}
}]
]
}
},
{
test: /\.(vue)$/,
loader: 'vue-loader',
},
{ test: /\.json$/, loader: "json-loader" },
{ test: /\.css$/, loader: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader"],
publicPath: "./"
}) },
{ test: /\.(png|jpg|gif)$/, loader: 'url-loader?limit=8192' }, // inline base64 URLs for <=8k images, direct URLs for the rest
{ test: /\.woff(2)?(\?v=[0-9\.]+)?$/, loader: "url-loader?prefix=font/&limit=5000" },
{ test: /\.(eot|ttf|svg)(\?v=[0-9\.]+)?$/, loader: "url-loader?prefix=font/&limit=5000" }
]
},
plugins: [
new CleanWebpackPlugin("dist"),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new UglifyJSPlugin({
test: /\.(js|vue)$/i,
uglifyOptions: {emca: 5}
}),
new ExtractTextPlugin('[name].bundle.css'),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.bundle\.css$/g,
// cssProcessor: require('cssnano'),
cssProcessorOptions: { discardComments: { removeAll: true } },
// canPrint: true
}),
new HtmlWebpackPlugin({
filename: '../index.html',
template: './source/index.template.html'
}),
new CopyWebpackPlugin([
// {from: "./source/README_master_branch.MD", to: "../README.MD",force: true },
// {from: "./source/*.png", to: "../[name].[ext]",force: true },
// {from: "./source/screenshots", to: "../screenshots",force: true, toType: "dir" },
], {
// debug: "info"
})
]
};
module.exports=config;