Showing
8 changed files
with
88 additions
and
58 deletions
1 | const webpack = require('webpack'); | 1 | const webpack = require('webpack'); |
2 | const path = require('path'); | 2 | const path = require('path'); |
3 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); | 3 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); |
4 | -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
5 | -var PostCompilePlugin = require('webpack-post-compile-plugin') | ||
6 | -var TransformModulesPlugin = require('webpack-transform-modules-plugin') | 4 | +var PostCompilePlugin = require('webpack-post-compile-plugin'); |
5 | +var TransformModulesPlugin = require('webpack-transform-modules-plugin'); | ||
7 | const VueLoaderPlugin = require('vue-loader/lib/plugin'); | 6 | const VueLoaderPlugin = require('vue-loader/lib/plugin'); |
8 | const pkg = require('../package.json'); | 7 | const pkg = require('../package.json'); |
9 | const isProd = process.env.NODE_ENV === 'production'; | 8 | const isProd = process.env.NODE_ENV === 'production'; |
@@ -47,47 +46,6 @@ const webpackConfig = { | @@ -47,47 +46,6 @@ const webpackConfig = { | ||
47 | test: /\.js$/, | 46 | test: /\.js$/, |
48 | use: 'babel-loader', | 47 | use: 'babel-loader', |
49 | exclude: /node_modules/ | 48 | exclude: /node_modules/ |
50 | - }, { | ||
51 | - test: /\.s?css$/, | ||
52 | - use: [ | ||
53 | - isProd ? MiniCssExtractPlugin.loader : 'vue-style-loader', | ||
54 | - 'css-loader', | ||
55 | - 'postcss-loader', | ||
56 | - { | ||
57 | - loader: 'sass-loader', | ||
58 | - options: { | ||
59 | - sourceMap: isProd | ||
60 | - } | ||
61 | - }] | ||
62 | - }, { | ||
63 | - test: /\.styl(us)?$/, | ||
64 | - use: [ | ||
65 | - isProd ? MiniCssExtractPlugin.loader : 'vue-style-loader', | ||
66 | - 'css-loader', | ||
67 | - 'postcss-loader', | ||
68 | - { | ||
69 | - loader: 'stylus-loader', | ||
70 | - options: { | ||
71 | - sourceMap: isProd, | ||
72 | - 'resolve url': true | ||
73 | - } | ||
74 | - }] | ||
75 | - }, { | ||
76 | - test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, | ||
77 | - use: { | ||
78 | - loader: 'file-loader', | ||
79 | - options: { | ||
80 | - name: 'static/img/[name].[hash:7].[ext]' | ||
81 | - } | ||
82 | - } | ||
83 | - }, { | ||
84 | - test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, | ||
85 | - use: { | ||
86 | - loader: 'file-loader', | ||
87 | - options: { | ||
88 | - name: 'static/img/[name].[hash:7].[ext]' | ||
89 | - } | ||
90 | - } | ||
91 | }, | 49 | }, |
92 | ] | 50 | ] |
93 | }, | 51 | }, |
@@ -100,13 +58,6 @@ const webpackConfig = { | @@ -100,13 +58,6 @@ const webpackConfig = { | ||
100 | ] | 58 | ] |
101 | }; | 59 | }; |
102 | 60 | ||
103 | -if (isProd) { | ||
104 | - webpackConfig.plugins.push( | ||
105 | - new MiniCssExtractPlugin({ | ||
106 | - filename: 'static/css/[name].[contenthash].css', | ||
107 | - allChunks: true | ||
108 | - }) | ||
109 | - ); | ||
110 | -} | 61 | + |
111 | 62 | ||
112 | module.exports = webpackConfig; | 63 | module.exports = webpackConfig; |
1 | const webpack = require('webpack'); | 1 | const webpack = require('webpack'); |
2 | const merge = require('webpack-merge'); | 2 | const merge = require('webpack-merge'); |
3 | +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
3 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | 4 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; |
4 | const VueSSRClientPlugin = require('vue-server-renderer/client-plugin'); | 5 | const VueSSRClientPlugin = require('vue-server-renderer/client-plugin'); |
5 | const pkg = require('../package.json'); | 6 | const pkg = require('../package.json'); |
6 | let baseConfig = require('./webpack.base.conf'); | 7 | let baseConfig = require('./webpack.base.conf'); |
8 | +const isProd = process.env.NODE_ENV === 'production'; | ||
7 | 9 | ||
8 | const webpackConfig = merge(baseConfig, { | 10 | const webpackConfig = merge(baseConfig, { |
9 | entry: { | 11 | entry: { |
@@ -43,6 +45,52 @@ const webpackConfig = merge(baseConfig, { | @@ -43,6 +45,52 @@ const webpackConfig = merge(baseConfig, { | ||
43 | } | 45 | } |
44 | } | 46 | } |
45 | }, | 47 | }, |
48 | + module: { | ||
49 | + rules: [ | ||
50 | + { | ||
51 | + test: /\.s?css$/, | ||
52 | + use: [ | ||
53 | + isProd ? MiniCssExtractPlugin.loader : 'vue-style-loader', | ||
54 | + 'css-loader', | ||
55 | + 'postcss-loader', | ||
56 | + { | ||
57 | + loader: 'sass-loader', | ||
58 | + options: { | ||
59 | + sourceMap: isProd | ||
60 | + } | ||
61 | + }] | ||
62 | + }, { | ||
63 | + test: /\.styl(us)?$/, | ||
64 | + use: [ | ||
65 | + isProd ? MiniCssExtractPlugin.loader : 'vue-style-loader', | ||
66 | + 'css-loader', | ||
67 | + 'postcss-loader', | ||
68 | + { | ||
69 | + loader: 'stylus-loader', | ||
70 | + options: { | ||
71 | + sourceMap: isProd, | ||
72 | + 'resolve url': true | ||
73 | + } | ||
74 | + }] | ||
75 | + }, { | ||
76 | + test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, | ||
77 | + use: { | ||
78 | + loader: 'file-loader', | ||
79 | + options: { | ||
80 | + name: 'static/img/[name].[hash:7].[ext]' | ||
81 | + } | ||
82 | + } | ||
83 | + }, { | ||
84 | + test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, | ||
85 | + use: { | ||
86 | + loader: 'file-loader', | ||
87 | + options: { | ||
88 | + name: 'static/img/[name].[hash:7].[ext]' | ||
89 | + } | ||
90 | + } | ||
91 | + } | ||
92 | + ] | ||
93 | + }, | ||
46 | resolve: { | 94 | resolve: { |
47 | alias: { | 95 | alias: { |
48 | 'create-api': 'common/create-api-client.js' | 96 | 'create-api': 'common/create-api-client.js' |
@@ -61,5 +109,12 @@ const webpackConfig = merge(baseConfig, { | @@ -61,5 +109,12 @@ const webpackConfig = merge(baseConfig, { | ||
61 | if (process.argv.some(a => a === '--report')) { | 109 | if (process.argv.some(a => a === '--report')) { |
62 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()); | 110 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()); |
63 | } | 111 | } |
64 | - | 112 | +if (isProd) { |
113 | + webpackConfig.plugins.push( | ||
114 | + new MiniCssExtractPlugin({ | ||
115 | + filename: 'static/css/[name].[contenthash].css', | ||
116 | + allChunks: true | ||
117 | + }) | ||
118 | + ); | ||
119 | +} | ||
65 | module.exports = webpackConfig; | 120 | module.exports = webpackConfig; |
@@ -17,11 +17,28 @@ let webpackConfig = merge(baseConfig, { | @@ -17,11 +17,28 @@ let webpackConfig = merge(baseConfig, { | ||
17 | 'create-api': 'common/create-api-server.js' | 17 | 'create-api': 'common/create-api-server.js' |
18 | } | 18 | } |
19 | }, | 19 | }, |
20 | + module: { | ||
21 | + rules: [ | ||
22 | + { | ||
23 | + test: /\.s?css$/, | ||
24 | + use: 'ignore-loader' | ||
25 | + }, { | ||
26 | + test: /\.styl(us)?$/, | ||
27 | + use: 'ignore-loader' | ||
28 | + }, { | ||
29 | + test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, | ||
30 | + use: 'ignore-loader' | ||
31 | + }, { | ||
32 | + test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, | ||
33 | + use: 'ignore-loader' | ||
34 | + } | ||
35 | + ] | ||
36 | + }, | ||
20 | output: { | 37 | output: { |
21 | libraryTarget: 'commonjs2', | 38 | libraryTarget: 'commonjs2', |
22 | }, | 39 | }, |
23 | externals: nodeExternals({ | 40 | externals: nodeExternals({ |
24 | - whitelist: [/\.css$/, /cube-ui/] | 41 | + whitelist: [/cube-ui/] |
25 | }), | 42 | }), |
26 | plugins: [ | 43 | plugins: [ |
27 | new VueSSRServerPlugin({ | 44 | new VueSSRServerPlugin({ |
@@ -57,7 +57,7 @@ module.exports = { | @@ -57,7 +57,7 @@ module.exports = { | ||
57 | activity: '//activity.yohobuy.com', | 57 | activity: '//activity.yohobuy.com', |
58 | index: '//m.yohobuy.com' | 58 | index: '//m.yohobuy.com' |
59 | }, | 59 | }, |
60 | - useCache: true, | 60 | + useCache: false, |
61 | loggers: { | 61 | loggers: { |
62 | infoFile: { | 62 | infoFile: { |
63 | close: true, | 63 | close: true, |
@@ -99,7 +99,6 @@ module.exports = { | @@ -99,7 +99,6 @@ module.exports = { | ||
99 | 99 | ||
100 | // host: '127.0.0.1', | 100 | // host: '127.0.0.1', |
101 | port: '6379', | 101 | port: '6379', |
102 | - password: '', | ||
103 | enable_offline_queue: false, | 102 | enable_offline_queue: false, |
104 | retry_strategy(options) { | 103 | retry_strategy(options) { |
105 | if (options.error && options.error.code === 'ECONNREFUSED') { | 104 | if (options.error && options.error.code === 'ECONNREFUSED') { |
@@ -214,7 +213,7 @@ if (isProduction) { | @@ -214,7 +213,7 @@ if (isProduction) { | ||
214 | ufo: process.env.UFO_API || 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/', | 213 | ufo: process.env.UFO_API || 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/', |
215 | service: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/' | 214 | service: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/' |
216 | }, | 215 | }, |
217 | - useCache: true, | 216 | + useCache: false, |
218 | monitorReport: { | 217 | monitorReport: { |
219 | host: '192.168.102.22', | 218 | host: '192.168.102.22', |
220 | port: 8086, | 219 | port: 8086, |
@@ -7,6 +7,7 @@ const yohoLib = require('yoho-node-lib'); | @@ -7,6 +7,7 @@ const yohoLib = require('yoho-node-lib'); | ||
7 | const pkg = require('./package.json'); | 7 | const pkg = require('./package.json'); |
8 | const devtools = require('./doraemon/middleware/devtools'); | 8 | const devtools = require('./doraemon/middleware/devtools'); |
9 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | +const Express = require('express'); | ||
10 | 11 | ||
11 | // 全局注册library | 12 | // 全局注册library |
12 | yohoLib.global(config); | 13 | yohoLib.global(config); |
@@ -35,6 +36,8 @@ exports.createApp = async(app) => { | @@ -35,6 +36,8 @@ exports.createApp = async(app) => { | ||
35 | // 添加请求上下文 | 36 | // 添加请求上下文 |
36 | app.use(global.yoho.httpCtx()); | 37 | app.use(global.yoho.httpCtx()); |
37 | 38 | ||
39 | + app.use('/static', Express.static('./dist/yohoblk-wap/bundle/static')); | ||
40 | + | ||
38 | app.use(global.yoho.hbs({ | 41 | app.use(global.yoho.hbs({ |
39 | extname: '.hbs', | 42 | extname: '.hbs', |
40 | defaultLayout: 'layout', | 43 | defaultLayout: 'layout', |
@@ -82,6 +82,7 @@ | @@ -82,6 +82,7 @@ | ||
82 | "file-loader": "^2.0.0", | 82 | "file-loader": "^2.0.0", |
83 | "friendly-errors-webpack-plugin": "^1.7.0", | 83 | "friendly-errors-webpack-plugin": "^1.7.0", |
84 | "husky": "^1.2.0", | 84 | "husky": "^1.2.0", |
85 | + "ignore-loader": "^0.1.2", | ||
85 | "memory-fs": "^0.4.1", | 86 | "memory-fs": "^0.4.1", |
86 | "mini-css-extract-plugin": "^0.5.0", | 87 | "mini-css-extract-plugin": "^0.5.0", |
87 | "node-sass": "^4.11.0", | 88 | "node-sass": "^4.11.0", |
@@ -3335,6 +3335,10 @@ ignore-by-default@^1.0.1: | @@ -3335,6 +3335,10 @@ ignore-by-default@^1.0.1: | ||
3335 | version "1.0.1" | 3335 | version "1.0.1" |
3336 | resolved "http://npm.yohops.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" | 3336 | resolved "http://npm.yohops.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" |
3337 | 3337 | ||
3338 | +ignore-loader@^0.1.2: | ||
3339 | + version "0.1.2" | ||
3340 | + resolved "http://npm.yohops.com/ignore-loader/-/ignore-loader-0.1.2.tgz#d81f240376d0ba4f0d778972c3ad25874117a463" | ||
3341 | + | ||
3338 | ignore-walk@^3.0.1: | 3342 | ignore-walk@^3.0.1: |
3339 | version "3.0.1" | 3343 | version "3.0.1" |
3340 | resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" | 3344 | resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" |
-
Please register or login to post a comment