forked from fabd/kanji-koohii
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
122 lines (99 loc) · 3.15 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
110
111
112
113
114
115
116
117
118
119
120
121
122
const webpack = require("webpack");
const isProduction = (process.env.NODE_ENV === 'production');
// Extract all the processed CSS in all Vue components into a single CSS file:
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
// https://github.com/webpack/extract-text-webpack-plugin
var ExtractTextPlugin = require("extract-text-webpack-plugin")
module.exports = {
// The base directory (absolute path!) for resolving the entry option.
// Note: __dirname refers to the root of your project.
//context: __dirname + "/src",
// Here the application starts executing and webpack starts bundling
entry: './lib/front/vue/vue-bundle.js',
output: {
// Webpack bundles everything to the output.path folder...
path: __dirname + '/web/build/pack',
// The publicPath specifies the public URL address of the output files when referenced in a browser
publicPath: "/build/pack/",
// ...naming it using the output.filename naming template
filename: isProduction ? "vue-bundle.min.js" : "vue-bundle.raw.js",
},
module: {
// module.rules is the same as module.loaders in 1.x
rules: [
{
test: /\.vue$/,
loader: "vue-loader",
// vue-loader options goes here
options: {
loaders: {
css: ExtractTextPlugin.extract({
loader: "css-loader",
fallbackLoader: "vue-style-loader" // <- this is a dep of vue-loader, so no need to explicitly install if using npm3
}),
js: "babel-loader"
}
}
},
{
// Ask webpack to check: If this file ends with .js, then apply some transforms
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/,
// Options are in .babelrc
//options: { presets: ["es2015"] }
},
/* FIXME : only in production + work with .vue files
{
// strip debug code
test: /\.js$/,
loader: "strip-loader?strip[]=core.log,strip[]=console.log",
exclude: /node_modules/,
},
*/
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
plugins: [
// web/build/pack/app-vue.css
new ExtractTextPlugin("app-vue.css"),
// remove all debug code (including Vue.js warnings) in production
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: isProduction ? '"production"' : '"development"'
}
})
],
resolve: {
// aliases used in lib/front/vue/vue-bundle.js
alias: {
vue: 'vue/dist/vue.common.js'
// coreJS: '/lib/front/vue/lib'
}
},
performance: {
// turn off asset size warnings in development build
hints: isProduction
}
}
if (process.env.NODE_ENV === 'production')
{
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.optimize.UglifyJsPlugin({
//fab-- sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}