mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: move webpack to root folder and rewrite to es6 node style (legacy compatibility)
This commit is contained in:
parent
6be3c6841c
commit
f8a7483b08
6 changed files with 42 additions and 37 deletions
|
@ -45,7 +45,8 @@
|
|||
"pkginfo": "^0.4.0",
|
||||
"request": "^2.72.0",
|
||||
"semver": "^5.1.0",
|
||||
"unix-crypt-td-js": "^1.0.0"
|
||||
"unix-crypt-td-js": "^1.0.0",
|
||||
"webpack-merge": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "0.16.2",
|
||||
|
@ -125,8 +126,8 @@
|
|||
"lint": "eslint .",
|
||||
"lint:css": "stylelint 'src/**/*.scss' --syntax scss",
|
||||
"build-docker": "docker build -t verdaccio .",
|
||||
"build:webui": "rimraf static/* && webpack --config src/webui/scripts/webpack.prod.config.babel.js",
|
||||
"dev:webui": "babel-node src/webui/scripts/dev.server.js",
|
||||
"build:webui": "rimraf static/* && webpack --config tools/webpack.prod.config.babel.js --debug",
|
||||
"dev:webui": "babel-node tools/dev.server.js",
|
||||
"prepublish": "in-publish && npm run build:webpack || not-in-publish",
|
||||
"build-docker:rpi": "docker build -f Dockerfile.rpi -t verdaccio:rpi ."
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ import webpack from 'webpack';
|
|||
import WebpackDevServer from 'webpack-dev-server';
|
||||
import config from './webpack.dev.config.babel';
|
||||
import ora from 'ora';
|
||||
import env from '../../config/env';
|
||||
import env from '../src/config/env';
|
||||
|
||||
const compiler = webpack(config);
|
||||
const spinner = ora('Compiler is running...').start();
|
|
@ -1,17 +1,17 @@
|
|||
import env from '../../config/env';
|
||||
const env = require('../src/config/env');
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
export default {
|
||||
module.exports = {
|
||||
entry: `${env.SRC_ROOT}/webui/src/index.js`,
|
||||
|
||||
output: {
|
||||
path: `${env.APP_ROOT}/static/`,
|
||||
filename: '[name].[hash].js'
|
||||
filename: '[name].[hash].js',
|
||||
},
|
||||
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx']
|
||||
extensions: ['.js', '.jsx'],
|
||||
},
|
||||
|
||||
module: {
|
||||
|
@ -19,14 +19,14 @@ export default {
|
|||
/* Pre loader */
|
||||
{
|
||||
enforce: 'pre',
|
||||
test: /\.jsx?$/,
|
||||
test: /\.js?$/,
|
||||
exclude: /node_modules/,
|
||||
use: 'eslint-loader'
|
||||
},
|
||||
|
||||
/* Normal loader */
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
test: /\.js?$/,
|
||||
exclude: /node_modules/,
|
||||
use: 'babel-loader'
|
||||
},
|
||||
|
@ -78,5 +78,7 @@ export default {
|
|||
|
||||
devtool: isDev ? 'source-map' : 'eval',
|
||||
|
||||
stats: {children: false}
|
||||
stats: {
|
||||
children: false
|
||||
}
|
||||
};
|
|
@ -2,7 +2,7 @@ import webpack from 'webpack';
|
|||
import HTMLWebpackPlugin from 'html-webpack-plugin';
|
||||
import FriendlyErrorsPlugin from 'friendly-errors-webpack-plugin';
|
||||
import baseConfig from './webpack.config';
|
||||
import env from '../../config/env';
|
||||
import env from '../src/config/env';
|
||||
|
||||
export default {
|
||||
...baseConfig,
|
|
@ -1,40 +1,30 @@
|
|||
import webpack from 'webpack';
|
||||
import HTMLWebpackPlugin from 'html-webpack-plugin';
|
||||
import ExtractTextPlugin from 'extract-text-webpack-plugin';
|
||||
import baseConfig from './webpack.config';
|
||||
import env from '../../config/env';
|
||||
import _ from 'lodash';
|
||||
const webpack = require('webpack');
|
||||
const HTMLWebpackPlugin = require('html-webpack-plugin');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const baseConfig = require('./webpack.config');
|
||||
const env = require('../src/config/env');
|
||||
const _ = require('lodash');
|
||||
const merge = require('webpack-merge');
|
||||
|
||||
baseConfig.module.rules
|
||||
.filter((loader) =>
|
||||
Array.isArray(loader.use) && loader.use.find((v) => /css/.test(v.loader.split('-')[0]))
|
||||
).forEach((loader) => {
|
||||
loader.use = ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: _.tail(loader.use)
|
||||
});
|
||||
});
|
||||
|
||||
export default {
|
||||
...baseConfig,
|
||||
const prodConf = {
|
||||
entry: {
|
||||
main: `${env.SRC_ROOT}/webui/src/index.js`
|
||||
main: `${env.SRC_ROOT}/webui/src/index.js`,
|
||||
},
|
||||
|
||||
output: {
|
||||
...baseConfig.output
|
||||
module: {
|
||||
rules: [],
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'__DEBUG__': false,
|
||||
'process.env.NODE_ENV': '"production"'
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
}),
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
sourceMap: true,
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
},
|
||||
}),
|
||||
new ExtractTextPlugin('style.[contenthash].css'),
|
||||
new HTMLWebpackPlugin({
|
||||
|
@ -45,6 +35,18 @@ export default {
|
|||
debug: false,
|
||||
inject: true,
|
||||
}),
|
||||
new webpack.NoEmitOnErrorsPlugin()
|
||||
]
|
||||
new webpack.NoEmitOnErrorsPlugin(),
|
||||
],
|
||||
};
|
||||
|
||||
prodConf.module.rules = baseConfig.module.rules
|
||||
.filter((loader) =>
|
||||
Array.isArray(loader.use) && loader.use.find((v) => /css/.test(v.loader.split('-')[0]))
|
||||
).forEach((loader) => {
|
||||
loader.use = ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: _.tail(loader.use),
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = merge(baseConfig, prodConf);
|
Loading…
Reference in a new issue