at the end of the day, it was inevitable

This commit is contained in:
Mo Elzubeir
2022-12-09 08:36:26 -06:00
commit 1218570914
1768 changed files with 887087 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import config from '../../config'
const isProduction = config.env === 'production'
const buildEntryPoint = function (entryPoint) {
let entry = [entryPoint]
if (!isProduction) {
entry.unshift(
'webpack-hot-middleware/client?path=/__webpack_hmr'
)
}
return entry
}
export const entry = {
'cw': buildEntryPoint(`${config.path_client}/main.js`)
}
export const output = {
libraryTarget: 'var',
library: 'CW',
filename: '[name].js',
path: config.path_dist,
publicPath: config.compiler_public_path
}
export const resolve = {
root: config.path_client,
extensions: ['', '.js']
}
+111
View File
@@ -0,0 +1,111 @@
import cssnano from 'cssnano'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import config from '../../config'
const isProduction = config.env === 'production'
// ------------------------------------
// Pre-Loaders
// ------------------------------------
export let preLoaders = [
{
test: /\.js$/,
loader: 'eslint',
exclude: /node_modules/
}
]
export let eslint = {
configFile: `${config.path_base}/.eslintrc`,
emitWarning: !isProduction
}
// ------------------------------------
// Loaders
// ------------------------------------
let sassLoaders = isProduction
? ExtractTextPlugin.extract(
'style-loader',
'css-loader!postcss-loader!sass-loader'
)
: 'style-loader!css-loader!postcss-loader!sass-loader'
let cssLoaders = isProduction
? ExtractTextPlugin.extract('style-loader', 'css-loader')
: 'style-loader!css-loader'
export let loaders = [
// ES-2015
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
compact: false,
query: {
cacheDirectory: true,
plugins: ['transform-runtime'],
presets: !isProduction
? ['es2015', 'react', 'stage-0', 'react-hmre']
: ['es2015', 'react', 'stage-0']
}
},
// Styles
{
test: /\.scss$/,
include: /app/,
loader: sassLoaders
},
{
test: /\.css$/,
exclude: /app/,
loader: cssLoaders
},
// Fonts
{
test: /\.woff(\?.*)?$/,
loader: 'file?prefix=fonts/&name=[path][name].[ext]'
},
{
test: /\.woff2(\?.*)?$/,
loader: 'file?prefix=fonts/&name=[path][name].[ext]'
},
{
test: /\.ttf(\?.*)?$/,
loader: 'file?prefix=fonts/&name=[path][name].[ext]'
},
{
test: /\.eot(\?.*)?$/,
loader: 'file?prefix=fonts/&name=[path][name].[ext]'
},
{
test: /\.svg(\?.*)?$/,
loader: 'file?prefix=fonts/&name=[path][name].[ext]'
},
// Images
{ test: /\.(png|jpg|gif)$/, loader: 'url' },
//json
{
test: /\.json$/,
loader: 'json-loader'
}
]
export let postcss = [
cssnano({
sourcemap: true,
autoprefixer: {
add: true,
remove: true,
browsers: ['last 2 versions']
},
safe: true,
discardComments: {
removeAll: true
}
})
]
export let sassLoader = {
includePaths: `${config.path_client}/styles`
}
+53
View File
@@ -0,0 +1,53 @@
import webpack from 'webpack'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import AddAssetHtmlPlugin from 'add-asset-html-webpack-plugin'
import config from '../../config'
const isProduction = config.env === 'production'
let htmlWebpackOptions = {
template: `${config.path_client}/index.html`,
hash: false,
favicon: `${config.path_client}/static/favicon.ico`,
filename: 'index.html',
inject: 'body'
}
if (isProduction) {
htmlWebpackOptions.minify = {
collapseWhitespace: true
}
}
export let plugins = [
new webpack.DefinePlugin(config.globals),
new webpack.DllReferencePlugin({
context: `${config.path_client}`,
manifest: require(config.path_dist + '/cw-vendors-manifest.json')
}),
new HtmlWebpackPlugin(htmlWebpackOptions),
new AddAssetHtmlPlugin({ filename: require.resolve(`${config.path_dist}/cw-vendors.js`), includeSourcemap: false })
]
if (!isProduction) {
plugins = plugins.concat([
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
])
}
else {
plugins = plugins.concat([
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false
}
}),
new ExtractTextPlugin('[name].css')
])
}