Commit acd4f63f4883d58bd0c8ad7aaf9d14a05dbc491f
Committed by
小小鲁班
1 parent
53719c81
Delete useless folders
Showing
1 changed file
with
0 additions
and
136 deletions
front-end/h5/build/engine.webpack.js deleted
100644 → 0
| 1 | -let path = require('path') | |
| 2 | -let env = { NODE_ENV: '"production"' } | |
| 3 | -let ora = require('ora') | |
| 4 | -let rm = require('rimraf') | |
| 5 | -let chalk = require('chalk') | |
| 6 | -let webpack = require('webpack') | |
| 7 | - | |
| 8 | -// 图片】字体等资源相对于 engineBuildOutputDir 的路径 | |
| 9 | -// 如果 assetsSubDirectory 填写/,则为 engine-assets/img, engine-assets/fonts | |
| 10 | -// 如果 assetsSubDirectory 填写/libs,则为 engine-assets/libs/img, engine-assets/libs/fonts | |
| 11 | -function assetsPath (_path) { | |
| 12 | - let assetsSubDirectory = '/' | |
| 13 | - return path.posix.join(assetsSubDirectory, _path) | |
| 14 | -} | |
| 15 | - | |
| 16 | -function resolve (dir) { | |
| 17 | - return path.join(__dirname, '..', dir) | |
| 18 | -} | |
| 19 | - | |
| 20 | -const engineBuildOutputDir = resolve('../../back-end/h5-api/public/engine-assets') | |
| 21 | - | |
| 22 | -process.env.NODE_ENV = 'production' | |
| 23 | - | |
| 24 | -let spinner = ora('building for production...') | |
| 25 | -spinner.start() | |
| 26 | - | |
| 27 | -let webpackConfig = { | |
| 28 | - mode: 'production', | |
| 29 | - entry: { | |
| 30 | - engine: './src/engine-entry.js' | |
| 31 | - }, | |
| 32 | - devtool: false, // or devtool: '#source-map', | |
| 33 | - output: { | |
| 34 | - path: engineBuildOutputDir, | |
| 35 | - filename: '[name].js', | |
| 36 | - // publicPath: '/public-path', | |
| 37 | - library: 'Engine' | |
| 38 | - }, | |
| 39 | - resolve: { | |
| 40 | - extensions: ['.js', '.vue', '.json'], | |
| 41 | - alias: { | |
| 42 | - 'vue$': 'vue/dist/vue.esm.js', | |
| 43 | - '@': resolve('src') | |
| 44 | - } | |
| 45 | - }, | |
| 46 | - externals: { | |
| 47 | - }, | |
| 48 | - module: { | |
| 49 | - rules: [ | |
| 50 | - { | |
| 51 | - test: /\.vue$/, | |
| 52 | - loader: 'vue-loader' | |
| 53 | - }, | |
| 54 | - { | |
| 55 | - test: /\.css$/, | |
| 56 | - use: [ | |
| 57 | - 'vue-style-loader', | |
| 58 | - { | |
| 59 | - loader: 'css-loader', | |
| 60 | - options: { | |
| 61 | - // enable CSS Modules | |
| 62 | - modules: true, | |
| 63 | - // customize generated class names | |
| 64 | - localIdentName: '[local]_[hash:base64:8]' | |
| 65 | - } | |
| 66 | - } | |
| 67 | - ] | |
| 68 | - }, | |
| 69 | - { | |
| 70 | - test: /\.scss$/, | |
| 71 | - use: [ | |
| 72 | - { | |
| 73 | - loader: 'vue-style-loader' // creates style nodes from JS strings | |
| 74 | - }, | |
| 75 | - { | |
| 76 | - loader: 'css-loader' // translates CSS into CommonJS | |
| 77 | - }, | |
| 78 | - { | |
| 79 | - loader: 'sass-loader' // compiles Sass to CSS | |
| 80 | - } | |
| 81 | - ] | |
| 82 | - }, | |
| 83 | - { | |
| 84 | - test: /\.js$/, | |
| 85 | - loader: 'babel-loader', | |
| 86 | - include: [resolve('src'), resolve('test')] | |
| 87 | - }, | |
| 88 | - { | |
| 89 | - test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, | |
| 90 | - loader: 'url-loader', | |
| 91 | - options: { | |
| 92 | - limit: 10000, | |
| 93 | - name: assetsPath('img/[name].[hash:7].[ext]') | |
| 94 | - } | |
| 95 | - }, | |
| 96 | - { | |
| 97 | - test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, | |
| 98 | - loader: 'url-loader', | |
| 99 | - options: { | |
| 100 | - limit: 10000, | |
| 101 | - name: assetsPath('fonts/[name].[hash:7].[ext]') | |
| 102 | - } | |
| 103 | - } | |
| 104 | - ] | |
| 105 | - }, | |
| 106 | - plugins: [ | |
| 107 | - new webpack.DefinePlugin({ | |
| 108 | - 'process.env': env | |
| 109 | - }) | |
| 110 | - ] | |
| 111 | -} | |
| 112 | - | |
| 113 | -rm(engineBuildOutputDir, err => { | |
| 114 | - if (err) throw err | |
| 115 | - webpack(webpackConfig, function (err, stats) { | |
| 116 | - spinner.stop() | |
| 117 | - if (err) throw err | |
| 118 | - process.stdout.write( | |
| 119 | - stats.toString({ | |
| 120 | - colors: true, | |
| 121 | - modules: true, | |
| 122 | - children: true, | |
| 123 | - chunks: true, | |
| 124 | - chunkModules: true | |
| 125 | - }) + '\n\n' | |
| 126 | - ) | |
| 127 | - | |
| 128 | - console.log(chalk.cyan(' Build complete.\n')) | |
| 129 | - console.log( | |
| 130 | - chalk.yellow( | |
| 131 | - ' Tip: built files are meant to be served over an HTTP server.\n' + | |
| 132 | - " Opening index.html over file:// won't work.\n" | |
| 133 | - ) | |
| 134 | - ) | |
| 135 | - }) | |
| 136 | -}) |