Commit fbb9e7f2 by 黑潮

update: build

parent ae7efd2a
{
"presets": [
["@babel/preset-env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": "2",
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}
}],
],
"@vue/babel-preset-jsx"
]
}
......@@ -2,6 +2,7 @@
module.exports = {
root: true,
parser: "vue-eslint-parser",
parserOptions: {
parser: '@babel/eslint-parser'
},
......
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
// const rm = require('rimraf')
// const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
// const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
// rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
// if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
......@@ -38,4 +31,3 @@ webpack(webpackConfig, (err, stats) => {
' Opening index.html over file:// won\'t work.\n'
))
})
// })
......@@ -2,9 +2,9 @@
const path = require('path');
module.exports = {
ouputDir: path.resolve(__dirname, '../dist'),
outputDir: '/dist3',
publicPath: '/marketing',
gzip: false,
productionGzip: false,
devServerProxy: {
'/api-.*/': {
target: 'http://gicdev.demogic.com',
......
/*
* @Author: luojie
* @Description:
* @Date: 2021-11-12 13:46:11
* @LastEditors: luojie
* @LastEditTime: 2021-11-12 13:46:12
* @FilePath: \marketing\build\dev-server.js
*/
'use strict';
const path = require('path');
const packageConfig = require('../package.json');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
exports.assetsPath = function(_path) {
return path.posix.join('static', _path);
......@@ -8,7 +9,7 @@ exports.assetsPath = function(_path) {
const cssLoaders = function() {
const sourceMap = process.env.NODE_ENV = 'production' ? false : true
const sourceMap = process.env.NODE_ENV === 'production' ? false : true
const cssLoader = {
loader: 'css-loader',
......
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}
......@@ -10,22 +10,23 @@ function resolve(dir) {
return path.join(__dirname, '..', dir);
}
const {outputDir = 'dist', publicPath = '/'} = config
module.exports = {
context: path.resolve(__dirname, '../'),
entry: ['./src/main.js'],
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
vue$: 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
output: {
path: config.ouputDir,
path: path.resolve(__dirname, '..', outputDir),
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js'),
clean: true,
publicPath: config.publicPath
publicPath: publicPath,
clean: true
},
module: {
rules: [
......@@ -77,6 +78,13 @@ module.exports = {
...utils.styleLoaders(),
]
},
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
'axios': 'axios',
'element-ui': 'ELEMENT'
},
plugins: [
new VueLoaderPlugin(),
// new ESLintPlugin({
......@@ -87,5 +95,6 @@ module.exports = {
new HtmlWebpackPlugin({
template: 'index.html',
})
]
],
stats: 'errors-only'
};
......@@ -4,62 +4,51 @@ const config = require('./config');
const { merge } = require('webpack-merge');
const path = require('path');
const baseWebpackConfig = require('./webpack.base.conf');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FriendlyErrorsPlugin = require('@soda/friendly-errors-webpack-plugin');
const portfinder = require('portfinder');
const PORT = '8080'
const {port = '8080', publicPath = '/', devServerProxy } = config
const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development',
devtool: 'eval-source-map',
devServer: {
client: {
logging: 'warning',
logging: 'warn',
overlay: true,
progress: true,
},
static: {
directory: path.join(__dirname, '../static'),
publicPath: path.posix.join(publicPath, 'static')
},
historyApiFallback: {
rewrites: [{ from: /.*/, to: path.posix.join(config.publicPath, 'index.html') }]
rewrites: [{ from: /.*/, to: path.posix.join(publicPath, 'index.html') }]
},
host: 'localhost',
port: PORT,
open: true,
proxy: config.devServerProxy,
port: port,
open: false,
proxy: devServerProxy,
watchFiles: {
options: {
usePolling: false,
},
}
},
plugins: [
// new webpack.HotModuleReplacementPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
}),
]
}
});
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = PORT;
portfinder.basePort = port;
portfinder.getPort((err, port) => {
if (err) {
reject(err);
} else {
// add port to devServer config
devWebpackConfig.devServer.port = port;
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`]
messages: [`Your application is running here: http://localhost:${port}`]
},
onErrors: utils.createNotifierCallback()
})
......
......@@ -3,9 +3,13 @@ const path = require('path');
const utils = require('./utils');
const webpack = require('webpack');
const config = require('./config');
const merge = require('webpack-merge');
const { merge } = require('webpack-merge');
const baseWebpackConfig = require('./webpack.base.conf');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { outputDir = 'dist', productionGzip = false } = config
const webpackConfig = merge(baseWebpackConfig, {
mode: 'production',
......@@ -16,30 +20,28 @@ const webpackConfig = merge(baseWebpackConfig, {
new CssMinimizerPlugin(),
],
},
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
'axios': 'axios',
'element-ui': 'ELEMENT'
},
plugins: [
new MiniCssExtractPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
}),
new webpack.HashedModuleIdsPlugin(),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.outputDir,
ignore: ['.*']
}
])
new webpack.ids.HashedModuleIdsPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, '../static'),
to: path.resolve(__dirname, '..', outputDir),
info: { minimized: true },
globOptions: {
ignore: ['.*']
}
}
]
})
]
});
if (config.productionGzip) {
if (productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin');
webpackConfig.plugins.push(
......
......@@ -15,7 +15,14 @@
<div id="app"></div>
<!-- built files will be auto injected -->
<!-- 组件引用cdn -->
<script>
(function() {
var src = '/component/static/import-component.js?timestrap=' + new Date().getTime();
var host = window.location.host;
host = host.indexOf('localhost') > -1 || host.indexOf('192.168') > -1 ? 'gicdev.demogic.com' : host;
document.write('<script src="//' + host + src + '"><\/script>');
})();
</script>
<!-- 4.0组件库中的组件 -->
<script src="//web-1251519181.file.myqcloud.com/components/pagination.1.0.8.js"></script><!-- 分页器 -->
<script src="//web-1251519181.file.myqcloud.com/components/track.1.0.4.js"></script>
......
......@@ -3537,12 +3537,12 @@
}
},
"bl": {
"version": "5.0.0",
"resolved": "https://registry.nlark.com/bl/download/bl-5.0.0.tgz",
"integrity": "sha1-aSiASkHp2pA0ho4cUMqI8h9XrqI=",
"version": "4.1.0",
"resolved": "https://registry.nlark.com/bl/download/bl-4.1.0.tgz",
"integrity": "sha1-RRU1JkGCvsL7vIOmKrmM8R2fezo=",
"dev": true,
"requires": {
"buffer": "^6.0.3",
"buffer": "^5.5.0",
"inherits": "^2.0.4",
"readable-stream": "^3.4.0"
}
......@@ -3663,13 +3663,13 @@
}
},
"buffer": {
"version": "6.0.3",
"resolved": "https://registry.nlark.com/buffer/download/buffer-6.0.3.tgz",
"integrity": "sha1-Ks5XhFnMj74qcKqo9S7mO2p0xsY=",
"version": "5.7.1",
"resolved": "https://registry.nlark.com/buffer/download/buffer-5.7.1.tgz",
"integrity": "sha1-umLnwTEzBTWCGXFghRqPZI6Z7tA=",
"dev": true,
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
"ieee754": "^1.1.13"
}
},
"buffer-from": {
......@@ -3852,12 +3852,12 @@
"dev": true
},
"cli-cursor": {
"version": "4.0.0",
"resolved": "https://registry.nlark.com/cli-cursor/download/cli-cursor-4.0.0.tgz?cache=0&sync_timestamp=1629747366550&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fcli-cursor%2Fdownload%2Fcli-cursor-4.0.0.tgz",
"integrity": "sha1-POz+NzS/T+Aqg2HL3A9v4oxqV+o=",
"version": "3.1.0",
"resolved": "https://registry.nlark.com/cli-cursor/download/cli-cursor-3.1.0.tgz?cache=0&sync_timestamp=1629747366550&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fcli-cursor%2Fdownload%2Fcli-cursor-3.1.0.tgz",
"integrity": "sha1-JkMFp65JDR0Dvwybp8kl0XU68wc=",
"dev": true,
"requires": {
"restore-cursor": "^4.0.0"
"restore-cursor": "^3.1.0"
}
},
"cli-spinners": {
......@@ -6453,9 +6453,9 @@
"dev": true
},
"is-interactive": {
"version": "2.0.0",
"resolved": "https://registry.nlark.com/is-interactive/download/is-interactive-2.0.0.tgz",
"integrity": "sha1-QMV2FFk4JtoRAK3mBZd41ZfxbpA=",
"version": "1.0.0",
"resolved": "https://registry.nlark.com/is-interactive/download/is-interactive-1.0.0.tgz",
"integrity": "sha1-zqbmrlyHCnsKAAQHC3tYfgJSkS4=",
"dev": true
},
"is-ip": {
......@@ -6564,9 +6564,9 @@
"dev": true
},
"is-unicode-supported": {
"version": "1.1.0",
"resolved": "https://registry.nlark.com/is-unicode-supported/download/is-unicode-supported-1.1.0.tgz?cache=0&sync_timestamp=1625294010675&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-unicode-supported%2Fdownload%2Fis-unicode-supported-1.1.0.tgz",
"integrity": "sha1-kSe3H5+oL1LKXCDpgue+wO4x7h4=",
"version": "0.1.0",
"resolved": "https://registry.nlark.com/is-unicode-supported/download/is-unicode-supported-0.1.0.tgz?cache=0&sync_timestamp=1625294010675&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-unicode-supported%2Fdownload%2Fis-unicode-supported-0.1.0.tgz",
"integrity": "sha1-PybHaoCVk7Ur+i7LVxDtJ3m1Iqc=",
"dev": true
},
"is-utf8": {
......@@ -6859,13 +6859,13 @@
"dev": true
},
"log-symbols": {
"version": "5.0.0",
"resolved": "https://registry.nlark.com/log-symbols/download/log-symbols-5.0.0.tgz",
"integrity": "sha1-dyDTxqVsNl4fZYkWBpuhjZQQkso=",
"version": "4.1.0",
"resolved": "https://registry.nlark.com/log-symbols/download/log-symbols-4.1.0.tgz",
"integrity": "sha1-P727lbRoOsn8eFER55LlWNSr1QM=",
"dev": true,
"requires": {
"chalk": "^4.1.0",
"is-unicode-supported": "^1.0.0"
"is-unicode-supported": "^0.1.0"
}
},
"longest": {
......@@ -7499,35 +7499,35 @@
}
},
"ora": {
"version": "6.0.1",
"resolved": "https://registry.nlark.com/ora/download/ora-6.0.1.tgz?cache=0&sync_timestamp=1631556513877&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fora%2Fdownload%2Fora-6.0.1.tgz",
"integrity": "sha1-aMqp/WxIWkDW9GxQo5QPo9+Zx/M=",
"dev": true,
"requires": {
"bl": "^5.0.0",
"chalk": "^4.1.2",
"cli-cursor": "^4.0.0",
"cli-spinners": "^2.6.0",
"is-interactive": "^2.0.0",
"is-unicode-supported": "^1.1.0",
"log-symbols": "^5.0.0",
"strip-ansi": "^7.0.1",
"version": "5.4.1",
"resolved": "https://registry.nlark.com/ora/download/ora-5.4.1.tgz?cache=0&sync_timestamp=1631556513877&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fora%2Fdownload%2Fora-5.4.1.tgz",
"integrity": "sha1-GyZ4Qmr0rEpQkAjl5KyemVnbnhg=",
"dev": true,
"requires": {
"bl": "^4.1.0",
"chalk": "^4.1.0",
"cli-cursor": "^3.1.0",
"cli-spinners": "^2.5.0",
"is-interactive": "^1.0.0",
"is-unicode-supported": "^0.1.0",
"log-symbols": "^4.1.0",
"strip-ansi": "^6.0.0",
"wcwidth": "^1.0.1"
},
"dependencies": {
"ansi-regex": {
"version": "6.0.1",
"resolved": "https://registry.nlark.com/ansi-regex/download/ansi-regex-6.0.1.tgz?cache=0&sync_timestamp=1631634988487&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fansi-regex%2Fdownload%2Fansi-regex-6.0.1.tgz",
"integrity": "sha1-MYPjj66aZdfLXlOUXNWJfQJgoGo=",
"version": "5.0.1",
"resolved": "https://registry.nlark.com/ansi-regex/download/ansi-regex-5.0.1.tgz?cache=0&sync_timestamp=1631634988487&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fansi-regex%2Fdownload%2Fansi-regex-5.0.1.tgz",
"integrity": "sha1-CCyyyJyf6GWaMRpTvWpNxTAdswQ=",
"dev": true
},
"strip-ansi": {
"version": "7.0.1",
"resolved": "https://registry.npmmirror.com/strip-ansi/download/strip-ansi-7.0.1.tgz",
"integrity": "sha1-YXQKCM42th5Q5lZT8HBg0ACXX7I=",
"version": "6.0.1",
"resolved": "https://registry.npmmirror.com/strip-ansi/download/strip-ansi-6.0.1.tgz",
"integrity": "sha1-nibGPTD1NEPpSJSVshBdN7Z6hdk=",
"dev": true,
"requires": {
"ansi-regex": "^6.0.1"
"ansi-regex": "^5.0.1"
}
}
}
......@@ -8599,9 +8599,9 @@
"dev": true
},
"restore-cursor": {
"version": "4.0.0",
"resolved": "https://registry.nlark.com/restore-cursor/download/restore-cursor-4.0.0.tgz",
"integrity": "sha1-UZVgpDGJdQlt725gnUQQDtqkzLk=",
"version": "3.1.0",
"resolved": "https://registry.nlark.com/restore-cursor/download/restore-cursor-3.1.0.tgz",
"integrity": "sha1-OfZ8VLOnpYzqUjbZXPADQjljH34=",
"dev": true,
"requires": {
"onetime": "^5.1.0",
......
......@@ -5,7 +5,7 @@
"author": "",
"private": true,
"scripts": {
"dev": "webpack --progress --config build/webpack.dev.conf.js",
"dev": "webpack server --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"build": "node build/build.js",
"format": "onchange 'test/**/*.js' 'src/**/*.js' 'src/**/*.vue' -- prettier --write {{changed}}"
......@@ -56,7 +56,7 @@
"mini-css-extract-plugin": "2.4.4",
"node-notifier": "10.0.0",
"node-sass": "4.14.1",
"ora": "6.0.1",
"ora": "^5.4.1",
"portfinder": "^1.0.27",
"postcss": "8.3.11",
"postcss-import": "^14.0.2",
......
......@@ -440,7 +440,6 @@ import memberAuth from './memberAuth';
// import axios from 'axios'
import qs from 'qs';
import { setTimeout } from 'timers';
export default {
name: 'links-tool',
......
......@@ -415,7 +415,6 @@ import GoodsTree from './goods-tree';
// import axios from 'axios'
import qs from 'qs';
import { setTimeout } from 'timers';
export default {
name: 'links-tool',
......
......@@ -321,7 +321,6 @@ import GoodsTree from './goods-tree';
// import axios from 'axios'
import qs from 'qs';
import { setTimeout } from 'timers';
export default {
name: 'links-tool',
......
const a = 1;
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