Commit 483cc9e2 authored by Evan You's avatar Evan You

update css-related externals

parent 6c9dd49a
...@@ -43,6 +43,15 @@ module.exports = { ...@@ -43,6 +43,15 @@ module.exports = {
limit: 10000, limit: 10000,
name: '[name].[ext]?[hash]' name: '[name].[ext]?[hash]'
} }
},
{
test: /\.css$/,
use: isProd
? ExtractTextPlugin.extract({
use: 'css-loader?minimize',
fallback: 'vue-style-loader'
})
: ['vue-style-loader', 'css-loader']
} }
] ]
}, },
......
...@@ -24,13 +24,13 @@ const config = merge(base, { ...@@ -24,13 +24,13 @@ const config = merge(base, {
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
name: 'vendor', name: 'vendor',
minChunks: function (module) { minChunks: function (module) {
// do not put CSS into the vendor chunk so that it can be extracted // a module is extracted into the vendor chunk if...
// otherwise extract-text-webpack-plugin will be confused return (
if (/\.(css|styl(us)?|less|sass|scss)(\?[^.]+)?$/.test(module.userRequest)) { // it's inside node_modules
return false /node_modules/.test(module.context) &&
} // and not a CSS file (due to extract-text-webpack-plugin limitation)
// this assumes your vendor imports exist in the node_modules directory !/\.css$/.test(module.request)
return module.context && module.context.indexOf('node_modules') !== -1 )
} }
}), }),
// extract webpack runtime & manifest to avoid vendor chunk hash changing // extract webpack runtime & manifest to avoid vendor chunk hash changing
......
const webpack = require('webpack') const webpack = require('webpack')
const merge = require('webpack-merge') const merge = require('webpack-merge')
const base = require('./webpack.base.config') const base = require('./webpack.base.config')
const nodeExternals = require('webpack-node-externals')
const VueSSRServerPlugin = require('vue-server-renderer/server-plugin') const VueSSRServerPlugin = require('vue-server-renderer/server-plugin')
module.exports = merge(base, { module.exports = merge(base, {
...@@ -16,9 +17,12 @@ module.exports = merge(base, { ...@@ -16,9 +17,12 @@ module.exports = merge(base, {
'create-api': './create-api-server.js' 'create-api': './create-api-server.js'
} }
}, },
// note: if a dependency needs to be processed by webpack, e.g. it exports // https://webpack.js.org/configuration/externals/#externals
// CSS or raw *.vue files, do not include it in externals! // https://github.com/liady/webpack-node-externals
externals: Object.keys(require('../package.json').dependencies), externals: nodeExternals({
// do not externalize CSS files in case we need to import it from a dep
whitelist: /\.css$/
}),
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'), 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
"vue-template-compiler": "^2.2.4", "vue-template-compiler": "^2.2.4",
"webpack": "^2.2.1", "webpack": "^2.2.1",
"webpack-dev-middleware": "^1.10.1", "webpack-dev-middleware": "^1.10.1",
"webpack-hot-middleware": "^2.17.1" "webpack-hot-middleware": "^2.17.1",
"webpack-node-externals": "^1.5.4"
} }
} }
...@@ -3521,6 +3521,10 @@ webpack-merge@^4.0.0: ...@@ -3521,6 +3521,10 @@ webpack-merge@^4.0.0:
dependencies: dependencies:
lodash "^4.17.4" lodash "^4.17.4"
webpack-node-externals@^1.5.4:
version "1.5.4"
resolved "https://registry.yarnpkg.com/webpack-node-externals/-/webpack-node-externals-1.5.4.tgz#ea05ba17108a23e776c35c42e7bb0e86c225be00"
webpack-sources@^0.1.0: webpack-sources@^0.1.0:
version "0.1.5" version "0.1.5"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.1.5.tgz#aa1f3abf0f0d74db7111c40e500b84f966640750" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.1.5.tgz#aa1f3abf0f0d74db7111c40e500b84f966640750"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment