Merge branch 'feature/hotreload' into 'release/1.0'
Feature/hotreload See merge request !4
Showing
20 changed files
with
421 additions
and
135 deletions
.eslintignore
0 → 100644
1 | +app/build/* |
app/build/build.js
0 → 100644
1 | +process.env.NODE_ENV = 'production' | ||
2 | + | ||
3 | +var ora = require('ora') | ||
4 | +var rm = require('rimraf') | ||
5 | +var path = require('path') | ||
6 | +var chalk = require('chalk') | ||
7 | +var webpack = require('webpack') | ||
8 | +var config = require('./config') | ||
9 | +var webpackConfig = require('./webpack.prod.conf') | ||
10 | + | ||
11 | +var spinner = ora('building for production...') | ||
12 | +spinner.start() | ||
13 | + | ||
14 | +rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { | ||
15 | + if (err) throw err | ||
16 | + webpack(webpackConfig, function (err, stats) { | ||
17 | + spinner.stop() | ||
18 | + if (err) throw err | ||
19 | + process.stdout.write(stats.toString({ | ||
20 | + colors: true, | ||
21 | + modules: false, | ||
22 | + children: false, | ||
23 | + chunks: false, | ||
24 | + chunkModules: false | ||
25 | + }) + '\n\n') | ||
26 | + | ||
27 | + console.log(chalk.cyan(' Build complete.\n')) | ||
28 | + console.log(chalk.yellow( | ||
29 | + ' Tip: built files are meant to be served over an HTTP server.\n' + | ||
30 | + ' Opening index.html over file:// won\'t work.\n' | ||
31 | + )) | ||
32 | + }) | ||
33 | +}) |
app/build/config.js
0 → 100644
1 | +var path = require('path') | ||
2 | + | ||
3 | +module.exports = { | ||
4 | + build: { | ||
5 | + env: { | ||
6 | + NODE_ENV: '"production"' | ||
7 | + }, | ||
8 | + index: path.resolve(__dirname, './bundle/index.html'), | ||
9 | + assetsRoot: path.resolve(__dirname, './bundle'), | ||
10 | + assetsSubDirectory: 'static', | ||
11 | + assetsPublicPath: '/', | ||
12 | + productionSourceMap: true, | ||
13 | + productionGzip: false, | ||
14 | + productionGzipExtensions: ['js', 'css'], | ||
15 | + bundleAnalyzerReport: process.env.npm_config_report, | ||
16 | + }, | ||
17 | + dev: { | ||
18 | + env: { | ||
19 | + NODE_ENV: '"dev"' | ||
20 | + }, | ||
21 | + port: 6008, | ||
22 | + autoOpenBrowser: true, | ||
23 | + assetsSubDirectory: 'static', | ||
24 | + assetsPublicPath: '/', | ||
25 | + proxyTable: { | ||
26 | + '/Api': 'http://localhost:6007' | ||
27 | + }, | ||
28 | + cssSourceMap: false, | ||
29 | + } | ||
30 | +} |
app/build/dev-client.js
0 → 100644
app/build/dev-server.js
0 → 100644
1 | +var config = require('./config') | ||
2 | +if (!process.env.NODE_ENV) { | ||
3 | + process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) | ||
4 | +} | ||
5 | + | ||
6 | +var opn = require('opn') | ||
7 | +var path = require('path') | ||
8 | +var express = require('express') | ||
9 | +var webpack = require('webpack') | ||
10 | +var proxyMiddleware = require('http-proxy-middleware') | ||
11 | +var webpackConfig = require('./webpack.dev.conf'); | ||
12 | + | ||
13 | +// default port where dev server listens for incoming traffic | ||
14 | +var port = process.env.PORT || config.dev.port | ||
15 | +// automatically open browser, if not set will be false | ||
16 | +var autoOpenBrowser = !!config.dev.autoOpenBrowser | ||
17 | +// Define HTTP proxies to your custom API backend | ||
18 | +// https://github.com/chimurai/http-proxy-middleware | ||
19 | +var proxyTable = config.dev.proxyTable | ||
20 | + | ||
21 | +var app = express() | ||
22 | +var compiler = webpack(webpackConfig) | ||
23 | + | ||
24 | +var devMiddleware = require('webpack-dev-middleware')(compiler, { | ||
25 | + publicPath: webpackConfig.output.publicPath, | ||
26 | + quiet: true, | ||
27 | + headers: { | ||
28 | + 'Access-Control-Allow-Origin': '*' | ||
29 | + }, | ||
30 | +}) | ||
31 | + | ||
32 | +var hotMiddleware = require('webpack-hot-middleware')(compiler, { | ||
33 | + log: () => {} | ||
34 | +}) | ||
35 | +// force page reload when html-webpack-plugin template changes | ||
36 | +compiler.plugin('compilation', function (compilation) { | ||
37 | + compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { | ||
38 | + hotMiddleware.publish({ action: 'reload' }) | ||
39 | + cb() | ||
40 | + }) | ||
41 | +}) | ||
42 | + | ||
43 | +// proxy api requests | ||
44 | +Object.keys(proxyTable).forEach(function (context) { | ||
45 | + var options = proxyTable[context] | ||
46 | + if (typeof options === 'string') { | ||
47 | + options = { target: options } | ||
48 | + } | ||
49 | + app.use(proxyMiddleware(options.filter || context, options)) | ||
50 | +}) | ||
51 | + | ||
52 | +// handle fallback for HTML5 history API | ||
53 | +app.use(require('connect-history-api-fallback')({ | ||
54 | + rewrites: [ | ||
55 | + { from: /\.html$/, to: '/index.html' }, | ||
56 | + { from: /.*?\.(js)|(css)$/, | ||
57 | + to: (context) => { | ||
58 | + return context.parsedUrl.pathname; | ||
59 | + } | ||
60 | + } | ||
61 | + ] | ||
62 | +})) | ||
63 | + | ||
64 | +// serve webpack bundle output | ||
65 | +app.use(devMiddleware) | ||
66 | + | ||
67 | +// enable hot-reload and state-preserving | ||
68 | +// compilation error display | ||
69 | +app.use(hotMiddleware) | ||
70 | + | ||
71 | +// serve pure static assets | ||
72 | +var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) | ||
73 | +app.use(staticPath, express.static('./static')) | ||
74 | + | ||
75 | +var uri = 'http://localhost:' + port | ||
76 | + | ||
77 | +var _resolve | ||
78 | +var readyPromise = new Promise(resolve => { | ||
79 | + _resolve = resolve | ||
80 | +}) | ||
81 | + | ||
82 | +console.log('> Starting dev server...') | ||
83 | +devMiddleware.waitUntilValid(() => { | ||
84 | + console.log('> Listening at ' + uri + '\n') | ||
85 | + // when env is testing, don't need open it | ||
86 | + if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { | ||
87 | + opn(uri) | ||
88 | + } | ||
89 | + _resolve() | ||
90 | +}) | ||
91 | + | ||
92 | +var server = app.listen(port) | ||
93 | + | ||
94 | +module.exports = { | ||
95 | + ready: readyPromise, | ||
96 | + close: () => { | ||
97 | + server.close() | ||
98 | + } | ||
99 | +} |
app/build/util.js
deleted
100644 → 0
app/build/utils.js
0 → 100644
1 | +var path = require('path') | ||
2 | +var config = require('./config') | ||
3 | +var ExtractTextPlugin = require('extract-text-webpack-plugin') | ||
4 | + | ||
5 | +exports.assetsPath = function (_path) { | ||
6 | + var assetsSubDirectory = process.env.NODE_ENV === 'production' | ||
7 | + ? config.build.assetsSubDirectory | ||
8 | + : config.dev.assetsSubDirectory | ||
9 | + return path.posix.join(assetsSubDirectory, _path) | ||
10 | +} | ||
11 | + | ||
12 | +exports.cssLoaders = function (options) { | ||
13 | + options = options || {} | ||
14 | + | ||
15 | + var cssLoader = { | ||
16 | + loader: 'css-loader', | ||
17 | + options: { | ||
18 | + minimize: process.env.NODE_ENV === 'production', | ||
19 | + sourceMap: options.sourceMap | ||
20 | + } | ||
21 | + } | ||
22 | + var autoprefixerLoader = { | ||
23 | + loader: 'autoprefixer-loader' | ||
24 | + } | ||
25 | + | ||
26 | + // generate loader string to be used with extract text plugin | ||
27 | + function generateLoaders (loader, loaderOptions) { | ||
28 | + var loaders = [cssLoader, autoprefixerLoader] | ||
29 | + if (loader) { | ||
30 | + loaders.push({ | ||
31 | + loader: loader + '-loader', | ||
32 | + options: Object.assign({}, loaderOptions, { | ||
33 | + sourceMap: options.sourceMap | ||
34 | + }) | ||
35 | + }) | ||
36 | + } | ||
37 | + | ||
38 | + // Extract CSS when that option is specified | ||
39 | + // (which is the case during production build) | ||
40 | + if (options.extract) { | ||
41 | + return ExtractTextPlugin.extract({ | ||
42 | + use: loaders, | ||
43 | + fallback: 'vue-style-loader' | ||
44 | + }) | ||
45 | + } else { | ||
46 | + return ['vue-style-loader'].concat(loaders) | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + // https://vue-loader.vuejs.org/en/configurations/extract-css.html | ||
51 | + return { | ||
52 | + css: generateLoaders(), | ||
53 | + postcss: generateLoaders(), | ||
54 | + less: generateLoaders('less'), | ||
55 | + sass: generateLoaders('sass', { indentedSyntax: true }), | ||
56 | + scss: generateLoaders('sass'), | ||
57 | + stylus: generateLoaders('stylus'), | ||
58 | + styl: generateLoaders('stylus') | ||
59 | + } | ||
60 | +} | ||
61 | + | ||
62 | +// Generate loaders for standalone style files (outside of .vue) | ||
63 | +exports.styleLoaders = function (options) { | ||
64 | + var output = [] | ||
65 | + var loaders = exports.cssLoaders(options) | ||
66 | + for (var extension in loaders) { | ||
67 | + var loader = loaders[extension] | ||
68 | + output.push({ | ||
69 | + test: new RegExp('\\.' + extension + '$'), | ||
70 | + use: loader | ||
71 | + }) | ||
72 | + } | ||
73 | + return output | ||
74 | +} |
app/build/vue-loader.conf.js
0 → 100644
1 | +var utils = require('./utils') | ||
2 | +var config = require('./config') | ||
3 | +var isProduction = process.env.NODE_ENV === 'production' | ||
4 | + | ||
5 | +module.exports = { | ||
6 | + loaders: utils.cssLoaders({ | ||
7 | + sourceMap: isProduction | ||
8 | + ? config.build.productionSourceMap | ||
9 | + : config.dev.cssSourceMap, | ||
10 | + extract: isProduction | ||
11 | + }) | ||
12 | +} |
1 | -const webpack = require('webpack'); | ||
2 | -const ExtractTextPlugin = require('extract-text-webpack-plugin'); | ||
3 | -const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
4 | -const CleanWebpackPlugin = require('clean-webpack-plugin'); | ||
5 | -const util = require('./util'); | 1 | +let utils = require('./utils'); |
2 | +var path = require('path'); | ||
3 | +let config = require('./config') | ||
4 | +let vueLoaderConfig = require('./vue-loader.conf') | ||
5 | + | ||
6 | +function resolve (dir) { | ||
7 | + return path.join(__dirname, '..', dir) | ||
8 | +} | ||
6 | 9 | ||
7 | module.exports = { | 10 | module.exports = { |
8 | entry: { | 11 | entry: { |
9 | - libs: ['vue', 'vue-router'], | ||
10 | - view: ['iview'], | ||
11 | - app: ['./app.js'] | 12 | + app: './app.js' |
12 | }, | 13 | }, |
13 | output: { | 14 | output: { |
14 | - path: util.resolve('./build/bundle'), | ||
15 | - filename: '[name].[hash:7].js', | ||
16 | - chunkFilename: '[name].[hash:7].js', | ||
17 | - publicPath: '/' | 15 | + path: config.build.assetsRoot, |
16 | + filename: 'js/[name].js', | ||
17 | + chunkFilename: 'js/[name].js', | ||
18 | + publicPath: process.env.NODE_ENV === 'production' | ||
19 | + ? config.build.assetsPublicPath | ||
20 | + : config.dev.assetsPublicPath | ||
18 | }, | 21 | }, |
19 | resolve: { | 22 | resolve: { |
20 | extensions: ['.js', '.vue', '.json'], | 23 | extensions: ['.js', '.vue', '.json'], |
@@ -22,43 +25,14 @@ module.exports = { | @@ -22,43 +25,14 @@ module.exports = { | ||
22 | vue$: 'vue/dist/vue.esm.js' | 25 | vue$: 'vue/dist/vue.esm.js' |
23 | }, | 26 | }, |
24 | modules: [ | 27 | modules: [ |
25 | - util.resolve(''), | ||
26 | - util.resolve('scss'), | ||
27 | - util.resolve('config'), | ||
28 | - util.resolve('services'), | ||
29 | - util.resolve('util'), | 28 | + resolve(''), |
29 | + resolve('scss'), | ||
30 | + resolve('config'), | ||
31 | + resolve('services'), | ||
32 | + resolve('util'), | ||
30 | 'node_modules' | 33 | 'node_modules' |
31 | ] | 34 | ] |
32 | }, | 35 | }, |
33 | - devServer: { | ||
34 | - host: '0.0.0.0', | ||
35 | - port: 6008, | ||
36 | - hot: false, | ||
37 | - inline: true, | ||
38 | - compress: true, | ||
39 | - stats: { | ||
40 | - colors: true, | ||
41 | - children: false, | ||
42 | - chunks: false, | ||
43 | - assetsSort: 'size', | ||
44 | - }, | ||
45 | - historyApiFallback: { | ||
46 | - rewrites: [ | ||
47 | - { from: /\.html$/, to: '/index.html' }, | ||
48 | - { from: /.*?\.(js)|(css)$/, | ||
49 | - to: (context) => { | ||
50 | - return context.parsedUrl.pathname; | ||
51 | - } | ||
52 | - } | ||
53 | - ] | ||
54 | - }, | ||
55 | - headers: { | ||
56 | - 'Access-Control-Allow-Origin': '*' | ||
57 | - }, | ||
58 | - proxy: { | ||
59 | - '/Api': 'http://localhost:6007' | ||
60 | - } | ||
61 | - }, | ||
62 | module: { | 36 | module: { |
63 | rules: [ | 37 | rules: [ |
64 | { | 38 | { |
@@ -71,7 +45,7 @@ module.exports = { | @@ -71,7 +45,7 @@ module.exports = { | ||
71 | loader: 'url-loader', | 45 | loader: 'url-loader', |
72 | options: { | 46 | options: { |
73 | limit: 10000, | 47 | limit: 10000, |
74 | - name: 'img/[name].[hash:7].[ext]' | 48 | + name: utils.assetsPath('img/[name].[hash:7].[ext]') |
75 | } | 49 | } |
76 | }, | 50 | }, |
77 | { | 51 | { |
@@ -79,50 +53,14 @@ module.exports = { | @@ -79,50 +53,14 @@ module.exports = { | ||
79 | loader: 'url-loader', | 53 | loader: 'url-loader', |
80 | options: { | 54 | options: { |
81 | limit: 10000, | 55 | limit: 10000, |
82 | - name: 'fonts/[name].[ext]' | 56 | + name: utils.assetsPath('fonts/[name].[hash:7].[ext]') |
83 | } | 57 | } |
84 | }, | 58 | }, |
85 | { | 59 | { |
86 | test: /\.vue$/, | 60 | test: /\.vue$/, |
87 | loader: 'vue-loader', | 61 | loader: 'vue-loader', |
88 | - options: { | ||
89 | - loaders: { | ||
90 | - scss: ExtractTextPlugin.extract({ | ||
91 | - use: 'css-loader!autoprefixer-loader!sass-loader', | ||
92 | - fallback: 'vue-style-loader' | ||
93 | - }) | ||
94 | - } | ||
95 | - } | ||
96 | - }, { | ||
97 | - test: /\.css$/, | ||
98 | - loader: ExtractTextPlugin.extract({ | ||
99 | - use: 'css-loader!autoprefixer-loader', | ||
100 | - fallback: 'style-loader' | ||
101 | - }) | ||
102 | - }, { | ||
103 | - test: /\.scss$/, | ||
104 | - loader: ExtractTextPlugin.extract({ | ||
105 | - use: 'css-loader!autoprefixer-loader!sass-loader', | ||
106 | - fallback: 'style-loader' | ||
107 | - }) | 62 | + options: vueLoaderConfig |
108 | } | 63 | } |
109 | ] | 64 | ] |
110 | - }, | ||
111 | - plugins: [ | ||
112 | - new ExtractTextPlugin('style.[hash:7].css'), | ||
113 | - new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), | ||
114 | - new HtmlWebpackPlugin({ | ||
115 | - filename: 'index.html', | ||
116 | - template: 'index.html', | ||
117 | - inject: true | ||
118 | - }), | ||
119 | - new webpack.optimize.CommonsChunkPlugin({ | ||
120 | - name: ['view', 'libs'], | ||
121 | - }), | ||
122 | - new CleanWebpackPlugin(['*'], { | ||
123 | - root: util.resolve('./build/bundle'), | ||
124 | - verbose: true, | ||
125 | - dry: false | ||
126 | - }) | ||
127 | - ] | 65 | + } |
128 | }; | 66 | }; |
1 | -const webpack = require('webpack'); | ||
2 | -let webpackConfig = require('./webpack.base.conf.js'); | 1 | +let webpack = require('webpack'); |
2 | +var path = require('path'); | ||
3 | +let config = require('./config') | ||
4 | +let utils = require('./utils'); | ||
5 | +let merge = require('webpack-merge') | ||
6 | +let HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
7 | +let baseConfig = require('./webpack.base.conf.js'); | ||
8 | +let FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') | ||
3 | 9 | ||
4 | -webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin()); | 10 | +Object.keys(baseConfig.entry).forEach(function (name) { |
11 | + baseConfig.entry[name] = ['./build/dev-client'].concat(baseConfig.entry[name]) | ||
12 | +}) | ||
5 | 13 | ||
14 | +module.exports = merge(baseConfig, { | ||
15 | + module: { | ||
16 | + rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) | ||
17 | + }, | ||
18 | + plugins: [ | ||
19 | + new webpack.DefinePlugin({ | ||
20 | + 'process.env': config.dev.env | ||
21 | + }), | ||
22 | + new webpack.HotModuleReplacementPlugin(), | ||
23 | + new webpack.NoEmitOnErrorsPlugin(), | ||
24 | + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), | ||
25 | + new HtmlWebpackPlugin({ | ||
26 | + filename: 'index.html', | ||
27 | + template: '../index.html', | ||
28 | + inject: true | ||
29 | + }), | ||
30 | + new FriendlyErrorsPlugin(), | ||
31 | + new webpack.optimize.CommonsChunkPlugin({ | ||
32 | + name: 'vendor', | ||
33 | + minChunks: function (module, count) { | ||
34 | + // any required modules inside node_modules are extracted to vendor | ||
35 | + return ( | ||
36 | + module.resource && | ||
37 | + /\.js$/.test(module.resource) && | ||
38 | + module.resource.indexOf( | ||
39 | + path.join(__dirname, '../../node_modules') | ||
40 | + ) === 0 | ||
41 | + ) | ||
42 | + } | ||
43 | + }), | ||
44 | + new webpack.optimize.CommonsChunkPlugin({ | ||
45 | + name: 'manifest', | ||
46 | + chunks: ['vendor'] | ||
47 | + }), | ||
48 | + ] | ||
49 | +}) | ||
6 | 50 | ||
7 | -module.exports = webpackConfig; |
1 | -const webpack = require('webpack'); | ||
2 | -const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin'); | ||
3 | -let webpackConfig = require('./webpack.base.conf.js'); | 1 | +let webpack = require('webpack'); |
2 | +var path = require('path'); | ||
3 | +let config = require('./config') | ||
4 | +let utils = require('./utils'); | ||
5 | +let merge = require('webpack-merge') | ||
6 | +let OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin'); | ||
7 | +let ExtractTextPlugin = require('extract-text-webpack-plugin'); | ||
8 | +let HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
9 | +let baseConfig = require('./webpack.base.conf.js'); | ||
4 | 10 | ||
5 | - | ||
6 | -webpackConfig.plugins.push(new webpack.DefinePlugin({ | ||
7 | - 'process.env': { | ||
8 | - NODE_ENV: '"production"' | ||
9 | - } | ||
10 | -})); | ||
11 | - | ||
12 | -webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({ | 11 | +var webpackConfig = merge(baseConfig, { |
12 | + module: { | ||
13 | + rules: utils.styleLoaders({ | ||
14 | + sourceMap: config.build.productionSourceMap, | ||
15 | + extract: true | ||
16 | + }) | ||
17 | + }, | ||
18 | + devtool: config.build.productionSourceMap ? '#source-map' : false, | ||
19 | + output: { | ||
20 | + path: config.build.assetsRoot, | ||
21 | + filename: utils.assetsPath('js/[name].[chunkhash:7].js'), | ||
22 | + chunkFilename: utils.assetsPath('js/[name].[chunkhash:7].js') | ||
23 | + }, | ||
24 | + plugins: [ | ||
25 | + new webpack.DefinePlugin({ | ||
26 | + 'process.env': config.build.env | ||
27 | + }), | ||
28 | + new webpack.optimize.UglifyJsPlugin({ | ||
13 | compress: { | 29 | compress: { |
14 | warnings: false | 30 | warnings: false |
15 | - } | ||
16 | -})); | ||
17 | -webpackConfig.plugins.push(new OptimizeCSSPlugin({ | 31 | + }, |
32 | + sourceMap: true | ||
33 | + }), | ||
34 | + new ExtractTextPlugin({ | ||
35 | + filename: utils.assetsPath('css/[name].[contenthash:7].css') | ||
36 | + }), | ||
37 | + new OptimizeCSSPlugin({ | ||
18 | cssProcessorOptions: { | 38 | cssProcessorOptions: { |
19 | safe: true | 39 | safe: true |
20 | } | 40 | } |
21 | -})); | 41 | + }), |
42 | + new HtmlWebpackPlugin({ | ||
43 | + filename: config.build.index, | ||
44 | + template: '../index.html', | ||
45 | + inject: true, | ||
46 | + minify: { | ||
47 | + removeComments: true, | ||
48 | + collapseWhitespace: true, | ||
49 | + removeAttributeQuotes: true | ||
50 | + }, | ||
51 | + chunksSortMode: 'dependency' | ||
52 | + }), | ||
53 | + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), | ||
54 | + new webpack.optimize.CommonsChunkPlugin({ | ||
55 | + name: 'vendor', | ||
56 | + minChunks: function (module, count) { | ||
57 | + // any required modules inside node_modules are extracted to vendor | ||
58 | + return ( | ||
59 | + module.resource && | ||
60 | + /\.js$/.test(module.resource) && | ||
61 | + module.resource.indexOf( | ||
62 | + path.join(__dirname, '../../node_modules') | ||
63 | + ) === 0 | ||
64 | + ) | ||
65 | + } | ||
66 | + }), | ||
67 | + new webpack.optimize.CommonsChunkPlugin({ | ||
68 | + name: 'manifest', | ||
69 | + chunks: ['vendor'] | ||
70 | + }) | ||
71 | + ] | ||
72 | +}); | ||
73 | + | ||
74 | +if (config.build.bundleAnalyzerReport) { | ||
75 | + var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin | ||
76 | + webpackConfig.plugins.push(new BundleAnalyzerPlugin()) | ||
77 | +} | ||
78 | + | ||
22 | 79 | ||
23 | 80 | ||
24 | module.exports = webpackConfig; | 81 | module.exports = webpackConfig; |
@@ -24,8 +24,7 @@ | @@ -24,8 +24,7 @@ | ||
24 | <em class="upload-img-tip">尺寸要求150px*150px 不大于500KB</em> | 24 | <em class="upload-img-tip">尺寸要求150px*150px 不大于500KB</em> |
25 | </Form-item> | 25 | </Form-item> |
26 | <Form-item label="店铺简介:"> | 26 | <Form-item label="店铺简介:"> |
27 | - <editor :content="shopData.shopIntro" | ||
28 | - @change="updateData"> | 27 | + <editor :content="shopData.shopIntro" @change="updateData" z-index="2"> |
29 | </editor> | 28 | </editor> |
30 | </Form-item> | 29 | </Form-item> |
31 | <Form-item label="品牌-供应商:"> | 30 | <Form-item label="品牌-供应商:"> |
@@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
2 | * 权限插件 | 2 | * 权限插件 |
3 | */ | 3 | */ |
4 | import _ from 'lodash'; | 4 | import _ from 'lodash'; |
5 | -import config from 'config'; | ||
6 | import axios from 'axios'; | 5 | import axios from 'axios'; |
7 | import userService from 'user-service'; | 6 | import userService from 'user-service'; |
8 | import iView from 'iview'; | 7 | import iView from 'iview'; |
@@ -10,7 +9,7 @@ import Rsa from 'rsa'; | @@ -10,7 +9,7 @@ import Rsa from 'rsa'; | ||
10 | 9 | ||
11 | const plugin = { | 10 | const plugin = { |
12 | updateUser(Vue, user, purviews) { | 11 | updateUser(Vue, user, purviews) { |
13 | - Vue.$store.set(config.storeKeys.user, Rsa.encrypt(user)); | 12 | + Vue.$store.set(Vue.$config.storeKeys.user, Rsa.encrypt(user)); |
14 | Vue.prop('user', user); | 13 | Vue.prop('user', user); |
15 | Vue.prop('isLogin', true); | 14 | Vue.prop('isLogin', true); |
16 | Vue.prop('purviews', purviews.deep); | 15 | Vue.prop('purviews', purviews.deep); |
@@ -18,7 +17,7 @@ const plugin = { | @@ -18,7 +17,7 @@ const plugin = { | ||
18 | }, | 17 | }, |
19 | 18 | ||
20 | // 权限验证 | 19 | // 权限验证 |
21 | - checkPurview(purviews, to) { | 20 | + checkPurview() { |
22 | return Promise.resolve(); | 21 | return Promise.resolve(); |
23 | 22 | ||
24 | // let pUrl = `/${_.split(to.name, '.').join('/')}`; | 23 | // let pUrl = `/${_.split(to.name, '.').join('/')}`; |
@@ -37,7 +36,7 @@ const plugin = { | @@ -37,7 +36,7 @@ const plugin = { | ||
37 | }, | 36 | }, |
38 | install(Vue) { | 37 | install(Vue) { |
39 | Vue.beforeRender((next) => { | 38 | Vue.beforeRender((next) => { |
40 | - let user = Vue.$store.get(config.storeKeys.user); | 39 | + let user = Vue.$store.get(Vue.$config.storeKeys.user); |
41 | let isLogin = Vue.$cookie.get('_isLogin'); | 40 | let isLogin = Vue.$cookie.get('_isLogin'); |
42 | 41 | ||
43 | if (isLogin && user) { | 42 | if (isLogin && user) { |
@@ -87,13 +86,13 @@ const plugin = { | @@ -87,13 +86,13 @@ const plugin = { | ||
87 | } | 86 | } |
88 | }; | 87 | }; |
89 | Vue.switchShop = shopsId => { | 88 | Vue.switchShop = shopsId => { |
90 | - Vue.$store.set(config.storeKeys.user, Rsa.encrypt(Vue.$user)); | 89 | + Vue.$store.set(Vue.$config.storeKeys.user, Rsa.encrypt(Vue.$user)); |
91 | Vue.$cookie.set('_sign', shopsId, { | 90 | Vue.$cookie.set('_sign', shopsId, { |
92 | path: '/' | 91 | path: '/' |
93 | }); | 92 | }); |
94 | }; | 93 | }; |
95 | Vue.logout = () => { | 94 | Vue.logout = () => { |
96 | - _.each(config.storeKeys, Vue.$store.remove); | 95 | + _.each(Vue.$config.storeKeys, Vue.$store.remove); |
97 | Vue.prop('user', void 0); | 96 | Vue.prop('user', void 0); |
98 | Vue.prop('isLogin', void 0); | 97 | Vue.prop('isLogin', void 0); |
99 | Vue.prop('purviews', void 0); | 98 | Vue.prop('purviews', void 0); |
@@ -91,8 +91,8 @@ const plugin = { | @@ -91,8 +91,8 @@ const plugin = { | ||
91 | Vue.prop('cookie', cookie); | 91 | Vue.prop('cookie', cookie); |
92 | 92 | ||
93 | // 设置axios默认参数 | 93 | // 设置axios默认参数 |
94 | - axios.defaults.baseURL = config.axiosBaseUrl; | ||
95 | - axios.defaults.responseType = config.axiosResponseType; | 94 | + axios.defaults.baseURL = Vue.$config.axiosBaseUrl; |
95 | + axios.defaults.responseType = Vue.$config.axiosResponseType; | ||
96 | } | 96 | } |
97 | }; | 97 | }; |
98 | 98 |
@@ -6,8 +6,8 @@ | @@ -6,8 +6,8 @@ | ||
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "dev": "nodemon server/app.js", | 8 | "dev": "nodemon server/app.js", |
9 | - "static": "cd app && webpack-dev-server --config ./build/webpack.dev.conf.js", | ||
10 | - "build": "cd app && webpack --config ./build/webpack.prod.conf.js", | 9 | + "static": "cd app && node ./build/dev-server.js", |
10 | + "build": "cd app && node ./build/build.js", | ||
11 | "lint-js": "eslint --ext .js,.vue -c .eslintrc --cache app server", | 11 | "lint-js": "eslint --ext .js,.vue -c .eslintrc --cache app server", |
12 | "lint-css": "stylelint --syntax scss --extract --config .stylelintrc **/*.vue", | 12 | "lint-css": "stylelint --syntax scss --extract --config .stylelintrc **/*.vue", |
13 | "precommit": "node lint-commit.js" | 13 | "precommit": "node lint-commit.js" |
@@ -40,7 +40,6 @@ | @@ -40,7 +40,6 @@ | ||
40 | "vue-html5-editor": "^1.1.1", | 40 | "vue-html5-editor": "^1.1.1", |
41 | "vue-router": "^2.2.0", | 41 | "vue-router": "^2.2.0", |
42 | "vue-template-compiler": "^2.2.6", | 42 | "vue-template-compiler": "^2.2.6", |
43 | - "webpack-dev-server": "^2.4.2", | ||
44 | "yoho-cookie": "^1.2.0", | 43 | "yoho-cookie": "^1.2.0", |
45 | "yoho-md5": "^2.0.0", | 44 | "yoho-md5": "^2.0.0", |
46 | "yoho-node-lib": "^0.2.18", | 45 | "yoho-node-lib": "^0.2.18", |
@@ -62,6 +61,7 @@ | @@ -62,6 +61,7 @@ | ||
62 | "babel-preset-es2015": "^6.24.1", | 61 | "babel-preset-es2015": "^6.24.1", |
63 | "babel-preset-stage-2": "^6.22.0", | 62 | "babel-preset-stage-2": "^6.22.0", |
64 | "babel-register": "^6.22.0", | 63 | "babel-register": "^6.22.0", |
64 | + "chalk": "^1.1.3", | ||
65 | "clean-webpack-plugin": "^0.1.16", | 65 | "clean-webpack-plugin": "^0.1.16", |
66 | "css-loader": "^0.26.1", | 66 | "css-loader": "^0.26.1", |
67 | "eslint": "^3.14.1", | 67 | "eslint": "^3.14.1", |
@@ -73,14 +73,18 @@ | @@ -73,14 +73,18 @@ | ||
73 | "eslint-plugin-promise": "^3.4.0", | 73 | "eslint-plugin-promise": "^3.4.0", |
74 | "eslint-plugin-standard": "^2.0.1", | 74 | "eslint-plugin-standard": "^2.0.1", |
75 | "eslint-plugin-vue": "^2.0.1", | 75 | "eslint-plugin-vue": "^2.0.1", |
76 | + "eventsource-polyfill": "^0.9.6", | ||
76 | "extract-text-webpack-plugin": "^2.0.0", | 77 | "extract-text-webpack-plugin": "^2.0.0", |
77 | "file-loader": "^0.10.0", | 78 | "file-loader": "^0.10.0", |
79 | + "friendly-errors-webpack-plugin": "^1.6.1", | ||
78 | "html-webpack-plugin": "^2.28.0", | 80 | "html-webpack-plugin": "^2.28.0", |
79 | "husky": "^0.13.3", | 81 | "husky": "^0.13.3", |
80 | "node-sass": "^4.5.2", | 82 | "node-sass": "^4.5.2", |
81 | "nodemon": "^1.11.0", | 83 | "nodemon": "^1.11.0", |
82 | "optimize-css-assets-webpack-plugin": "^1.3.0", | 84 | "optimize-css-assets-webpack-plugin": "^1.3.0", |
85 | + "ora": "^1.2.0", | ||
83 | "resolve-url-loader": "^2.0.2", | 86 | "resolve-url-loader": "^2.0.2", |
87 | + "rimraf": "^2.6.1", | ||
84 | "sass-loader": "^6.0.3", | 88 | "sass-loader": "^6.0.3", |
85 | "style-loader": "^0.16.1", | 89 | "style-loader": "^0.16.1", |
86 | "stylelint": "^7.10.1", | 90 | "stylelint": "^7.10.1", |
@@ -92,6 +96,10 @@ | @@ -92,6 +96,10 @@ | ||
92 | "vue-loader": "^11.1.4", | 96 | "vue-loader": "^11.1.4", |
93 | "vue-style-loader": "^2.0.0", | 97 | "vue-style-loader": "^2.0.0", |
94 | "webpack": "^2.2.1", | 98 | "webpack": "^2.2.1", |
99 | + "webpack-dev-middleware": "^1.10.2", | ||
100 | + "webpack-dev-server": "^2.4.2", | ||
101 | + "webpack-hot-middleware": "^2.18.0", | ||
102 | + "webpack-merge": "^4.1.0", | ||
95 | "webpack-px-to-rem": "^0.1.0" | 103 | "webpack-px-to-rem": "^0.1.0" |
96 | }, | 104 | }, |
97 | "author": "", | 105 | "author": "", |
-
Please register or login to post a comment