|
@@ -1,6 +1,20 @@
|
|
|
const path = require('path');
|
|
const path = require('path');
|
|
|
|
|
+const fs = require('fs');
|
|
|
|
|
+const UploadPlugin = require('./upload');
|
|
|
|
|
+let publicPath;
|
|
|
|
|
+switch (process.env.NODE_ENV) {
|
|
|
|
|
+ case 'development':
|
|
|
|
|
+ publicPath = '/';
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'production':
|
|
|
|
|
+ publicPath = `https://cosmoscdn.9space.vip/www/` + new Date().getTime();
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'test':
|
|
|
|
|
+ publicPath = `https://cosmoscdn.9space.vip/www_test/` + new Date().getTime();
|
|
|
|
|
+ break;
|
|
|
|
|
+}
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
- publicPath: process.env.PUBLIC_PATH || '/',
|
|
|
|
|
|
|
+ publicPath: publicPath,
|
|
|
devServer: {
|
|
devServer: {
|
|
|
port: 8081,
|
|
port: 8081,
|
|
|
disableHostCheck: true
|
|
disableHostCheck: true
|
|
@@ -12,6 +26,9 @@ module.exports = {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
chainWebpack: config => {
|
|
chainWebpack: config => {
|
|
|
|
|
+ if (process.env.NODE_ENV === 'production') {
|
|
|
|
|
+ config.plugin('upload').use(new UploadPlugin(publicPath.replace('https://cosmoscdn.9space.vip/', '')));
|
|
|
|
|
+ }
|
|
|
config.output.filename('[name].[hash].js').end();
|
|
config.output.filename('[name].[hash].js').end();
|
|
|
config.resolve.alias.set('@assets', path.resolve(__dirname, 'src', 'assets', process.env.ASSETS_PATH || '9th'));
|
|
config.resolve.alias.set('@assets', path.resolve(__dirname, 'src', 'assets', process.env.ASSETS_PATH || '9th'));
|
|
|
config.plugin('html').tap(args => {
|
|
config.plugin('html').tap(args => {
|