First Committ
This commit is contained in:
27
config/envparser.js
Executable file
27
config/envparser.js
Executable file
@@ -0,0 +1,27 @@
|
||||
const DotEnv = require('dotenv')
|
||||
|
||||
let path
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'test':
|
||||
path = '.env.test'
|
||||
break
|
||||
case 'development':
|
||||
path = '.env.development'
|
||||
break
|
||||
default:
|
||||
path = '.env.production'
|
||||
break
|
||||
}
|
||||
|
||||
// console.log("PATH", path)
|
||||
const parsedEnv = DotEnv.config({ path }).parsed;
|
||||
|
||||
module.exports = function () {
|
||||
// Let's stringify our variables
|
||||
for (const key in parsedEnv) {
|
||||
if (typeof parsedEnv[key] === 'string') {
|
||||
// parsedEnv[key] = JSON.stringify(parsedEnv[key])
|
||||
}
|
||||
}
|
||||
return parsedEnv
|
||||
};
|
||||
3
config/helpers/env.js
Executable file
3
config/helpers/env.js
Executable file
@@ -0,0 +1,3 @@
|
||||
module.exports = function (key, fallback) {
|
||||
return process.env[key] || fallback
|
||||
}
|
||||
120
config/webpack.config.base.js
Executable file
120
config/webpack.config.base.js
Executable file
@@ -0,0 +1,120 @@
|
||||
const path = require('path');
|
||||
const webpack = require('webpack')
|
||||
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const cssNext = require('postcss-cssnext');
|
||||
const postcssImport = require('postcss-import');
|
||||
const helpers = require('./helpers');
|
||||
|
||||
const baseConfig = {
|
||||
entry: {
|
||||
bundle: path.resolve(__dirname, '/src/main.ts'),
|
||||
},
|
||||
output: {
|
||||
filename: '[nametranslate].js',
|
||||
publicPath: '/',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
},
|
||||
resolve: {
|
||||
extensions: [
|
||||
'.ts', '.js', '.vue',
|
||||
],
|
||||
alias: {
|
||||
vue: '@vue/compat',
|
||||
'@components': path.resolve(__dirname, 'src/components/index.ts'),
|
||||
'@boot': path.resolve(__dirname, 'src/boot/*'),
|
||||
'@costanti': path.resolve(__dirname, 'src/store/Modules/costanti.ts'),
|
||||
'@views': path.resolve(__dirname, 'src/views/index.ts'),
|
||||
'@': path.resolve(__dirname, 'src'),
|
||||
'@src': path.resolve(__dirname, 'src'),
|
||||
'@icons': path.resolve(__dirname, 'src/assets/icons'),
|
||||
'@images': path.resolve(__dirname, 'src/assets/images'),
|
||||
'@classes': path.resolve(__dirname, 'src/classes/index.ts'),
|
||||
'@fonts': path.resolve(__dirname, 'src/assets/fonts'),
|
||||
'@utils': path.resolve(__dirname, 'src/utils/index.ts'),
|
||||
'@css': path.resolve(__dirname, 'src/styles/variables.scss'),
|
||||
'@router': path.resolve(__dirname, 'src/router/index.ts'),
|
||||
'@validators': path.resolve(__dirname, 'src/utils/validators.ts'),
|
||||
'@methods': path.resolve(__dirname, 'src/utils/methods.ts'),
|
||||
'@filters': path.resolve(__dirname, 'src/utils/filters.ts'),
|
||||
'@api': path.resolve(__dirname, 'src/store/Api/index.ts'),
|
||||
'@paths': path.resolve(__dirname, 'src/store/Api/ApiRoutes.ts'),
|
||||
'@storemod': path.resolve(__dirname, 'src/store/Modules/*'),
|
||||
'@store/*': path.resolve(__dirname, 'src/store/*'),
|
||||
'@modules': path.resolve(__dirname, 'src/store/Modules/index.ts'),
|
||||
'@model': path.resolve(__dirname, 'src/model/index.ts'),
|
||||
},
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.vue$/,
|
||||
use: {
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
compilerOptions: {
|
||||
compatConfig: {
|
||||
MODE: 2,
|
||||
},
|
||||
},
|
||||
postcss: {
|
||||
plugins: [cssNext()],
|
||||
options: {
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
cssSourceMap: true,
|
||||
loaders: {
|
||||
scss: ['vue-style-loader', 'css-loader', 'sass-loader', {
|
||||
loader: 'sass-resources-loader',
|
||||
options: {
|
||||
resources: path.resolve(__dirname, 'src/styles/variables.scss'),
|
||||
esModule: true,
|
||||
},
|
||||
}],
|
||||
ts: 'ts-loader',
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
test: /\.ts$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
appendTsSuffixTo: [/\.vue$/],
|
||||
},
|
||||
}, {
|
||||
test: /\.(jpe?g|png|ttf|eot|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
||||
use: 'base64-inline-loader?limit=1000&nametranslate=[nametranslate].[ext]',
|
||||
}, {
|
||||
test: /\.(svg)(\?[a-z0-9=&.]+)?$/,
|
||||
use: 'base64-inline-loader?limit=4000&nametranslate=[nametranslate].[ext]',
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new FaviconsWebpackPlugin({
|
||||
logo: path.resolve(__dirname, 'src/assets/images/logo_M.png'),
|
||||
persistentCache: true,
|
||||
inject: true,
|
||||
background: '#fff',
|
||||
icons: {
|
||||
android: false,
|
||||
appleIcon: false,
|
||||
appleStartup: false,
|
||||
coast: false,
|
||||
favicons: true,
|
||||
firefox: false,
|
||||
opengraph: false,
|
||||
twitter: false,
|
||||
yandex: false,
|
||||
windows: false,
|
||||
},
|
||||
}),
|
||||
new CopyWebpackPlugin([{
|
||||
from: path.resolve(__dirname, 'src/assets'),
|
||||
}]),
|
||||
],
|
||||
};
|
||||
|
||||
module.exports = baseConfig;
|
||||
90
config/webpack.config.dev.js
Executable file
90
config/webpack.config.dev.js
Executable file
@@ -0,0 +1,90 @@
|
||||
const webpack = require('webpack')
|
||||
const path = require('path');
|
||||
const merge = require('webpack-merge')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
||||
const WebpackDashboard = require('webpack-dashboard/plugin');
|
||||
const DefinePlugin = require('webpack/lib/DefinePlugin');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const helpers = require('./helpers');
|
||||
const env = require('../environment/dev.env');
|
||||
const webpackBaseConfig = require('./webpack.config.base');
|
||||
|
||||
const webpackDevConfig = {
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.s?css$/,
|
||||
use: [{
|
||||
loader: 'style-loader',
|
||||
}, {
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
minimize: false,
|
||||
sourceMap: true,
|
||||
importLoaders: 2,
|
||||
},
|
||||
}, {
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
plugins: () => [autoprefixer],
|
||||
sourceMap: true,
|
||||
},
|
||||
}, {
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
outputStyle: 'expanded',
|
||||
sourceMap: true,
|
||||
sourceMapContents: true,
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true,
|
||||
template: helpers.root('/src/index.html'),
|
||||
filename: 'index.html',
|
||||
favicon: helpers.root('/src/assets/images/logo_M.png'),
|
||||
}),
|
||||
new DefinePlugin({
|
||||
'process.env': env,
|
||||
}),
|
||||
new WebpackDashboard(),
|
||||
new FriendlyErrorsPlugin(),
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NamedModulesPlugin(),
|
||||
],
|
||||
devServer: {
|
||||
contentBase: path.join(__dirname, 'dist'),
|
||||
port: 5000,
|
||||
historyApiFallback: true,
|
||||
disableHostCheck: true,
|
||||
host: '0.0.0.0',
|
||||
hot: true,
|
||||
open: true,
|
||||
quiet: true,
|
||||
inline: true,
|
||||
noInfo: true,
|
||||
stats: {
|
||||
colors: true,
|
||||
hash: false,
|
||||
version: false,
|
||||
timings: false,
|
||||
assets: false,
|
||||
chunks: false,
|
||||
modules: false,
|
||||
reasons: false,
|
||||
children: false,
|
||||
source: false,
|
||||
errors: true,
|
||||
errorDetails: true,
|
||||
warnings: false,
|
||||
publicPath: false,
|
||||
},
|
||||
},
|
||||
devtool: 'cheap-module-eval-source-map',
|
||||
}
|
||||
|
||||
const devExport = merge(webpackBaseConfig, webpackDevConfig);
|
||||
|
||||
module.exports = devExport;
|
||||
Reference in New Issue
Block a user