Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 36 additions & 29 deletions build/webpack.base.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')

const isProd = process.env.NODE_ENV === 'production'
const NODE_ENV = process.env.NODE_ENV || 'development'

const isProd = NODE_ENV === 'production'

module.exports = {
mode: NODE_ENV,
devtool: isProd
? false
: '#cheap-module-source-map',
Expand Down Expand Up @@ -47,38 +50,42 @@ module.exports = {
},
{
test: /\.styl(us)?$/,
use: isProd
? ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: { minimize: true }
},
'stylus-loader'
],
fallback: 'vue-style-loader'
})
: ['vue-style-loader', 'css-loader', 'stylus-loader']
oneOf: [
{
test: /App/,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please can you give some explanations about this test ? thanks

resourceQuery: /\?vue/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { minimize: isProd }
},
'stylus-loader'
]
},
{
use: [
'vue-style-loader',
{
loader: 'css-loader',
options: { minimize: isProd }
},
'stylus-loader'
]
}
]
},
]
},
performance: {
maxEntrypointSize: 300000,
hints: isProd ? 'warning' : false
},
plugins: isProd
? [
new VueLoaderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new ExtractTextPlugin({
filename: 'common.[chunkhash].css'
})
]
: [
new VueLoaderPlugin(),
new FriendlyErrorsPlugin()
]
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: 'common.[chunkhash].css'
}),
... isProd ? [] : [ new FriendlyErrorsPlugin() ]
]
}
44 changes: 25 additions & 19 deletions build/webpack.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,38 @@ const config = merge(base, {
resolve: {
alias: {
'create-api': './create-api-client.js'
},
},
optimization: {
// extract webpack runtime & manifest to avoid vendor chunk hash changing
// on every build.
runtimeChunk: {
name: 'manifest',
},
// extract vendor chunks for better caching
splitChunks: {
chunks: 'initial',
cacheGroups: {
vendor: {
name: 'vendor',
test(module) {
// a module is extracted into the vendor chunk if...
return (
// it's inside node_modules
/node_modules/.test(module.context) &&
// and not a CSS file
!/\.css$/.test(module.request)
)
}
}
}
}
},
plugins: [
// strip dev-only code in Vue source
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env.VUE_ENV': '"client"'
}),
// extract vendor chunks for better caching
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
// a module is extracted into the vendor chunk if...
return (
// it's inside node_modules
/node_modules/.test(module.context) &&
// and not a CSS file (due to extract-text-webpack-plugin limitation)
!/\.css$/.test(module.request)
)
}
}),
// extract webpack runtime & manifest to avoid vendor chunk hash changing
// on every build.
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
}),
new VueSSRClientPlugin()
]
})
Expand Down
1 change: 0 additions & 1 deletion build/webpack.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module.exports = merge(base, {
}),
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env.VUE_ENV': '"server"'
}),
new VueSSRServerPlugin()
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
"cross-env": "^5.1.1",
"es6-promise": "^4.1.1",
"express": "^4.16.2",
"extract-text-webpack-plugin": "^3.0.2",
"firebase": "4.6.2",
"firebase": "^4.12.0",
"lru-cache": "^4.1.1",
"route-cache": "0.4.3",
"route-cache": "0.4.4",
"serve-favicon": "^2.4.5",
"vue": "^2.5.16",
"vue-router": "^3.0.1",
Expand All @@ -31,24 +30,26 @@
"vuex-router-sync": "^5.0.0"
},
"devDependencies": {
"autoprefixer": "^7.1.6",
"autoprefixer": "^8.2.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-preset-env": "^1.6.1",
"chokidar": "^1.7.0",
"css-loader": "^0.28.7",
"chokidar": "^2.0.3",
"css-loader": "^0.28.11",
"file-loader": "^1.1.5",
"friendly-errors-webpack-plugin": "^1.6.1",
"mini-css-extract-plugin": "^0.2.0",
"rimraf": "^2.6.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"sw-precache-webpack-plugin": "^0.11.4",
"url-loader": "^0.6.2",
"vue-loader": "^15.0.0-beta.1",
"url-loader": "^1.0.1",
"vue-loader": "^15.0.0-beta.7",
"vue-template-compiler": "^2.5.16",
"webpack": "^3.8.1",
"webpack-dev-middleware": "^1.12.0",
"webpack": "^4.3.0",
"webpack-cli": "^2.0.13",
"webpack-dev-middleware": "^3.1.0",
"webpack-hot-middleware": "^2.20.0",
"webpack-merge": "^4.1.1",
"webpack-node-externals": "^1.6.0"
Expand Down
Loading