Update webpack
This commit is contained in:
@@ -15,24 +15,23 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
// const ReactIntlAggregatePlugin = require('react-intl-aggregate-webpack-plugin');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const WebpackErrorNotificationPlugin = require('webpack-error-notification');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
|
||||
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
|
||||
|
||||
const rulesEs6 = require('./rules/es6');
|
||||
const rulesParity = require('./rules/parity');
|
||||
const Shared = require('./shared');
|
||||
|
||||
const DAPPS_BUILTIN = require('@parity/shared/config/dappsBuiltin.json');
|
||||
const DAPPS_VIEWS = require('@parity/shared/config/dappsViews.json').map((dapp) => {
|
||||
dapp.commons = true;
|
||||
return dapp;
|
||||
});
|
||||
const DAPPS_BUILTIN = []; // require('@parity/shared/config/dappsBuiltin.json');
|
||||
const DAPPS_VIEWS = []; // require('@parity/shared/config/dappsViews.json').map((dapp) => {
|
||||
// dapp.commons = true;
|
||||
// return dapp;
|
||||
// });
|
||||
|
||||
const FAVICON = path.resolve(__dirname, '../node_modules/@parity/shared/assets/images/parity-logo-black-no-text.png');
|
||||
|
||||
@@ -59,9 +58,8 @@ module.exports = {
|
||||
context: path.join(__dirname, '../src'),
|
||||
entry: entry,
|
||||
output: {
|
||||
// publicPath: '/',
|
||||
path: path.join(__dirname, '../', DEST),
|
||||
filename: '[name].[hash:10].js'
|
||||
filename: '[name].js'
|
||||
},
|
||||
|
||||
module: {
|
||||
@@ -106,31 +104,24 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
include: [ /packages/, /src/, /@parity/ ],
|
||||
use: [
|
||||
'style-loader',
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
importLoaders: 1,
|
||||
localIdentName: '[name]_[local]_[hash:base64:5]'
|
||||
importLoaders: 1
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
'postcss-import': {},
|
||||
'postcss-nested': {},
|
||||
'postcss-neted': {},
|
||||
'postcss-simple-vars': {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
exclude: [ /packages/, /src/, /@parity/ ],
|
||||
use: [ 'style-loader', 'css-loader' ]
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpg)$/,
|
||||
use: [ {
|
||||
@@ -204,12 +195,16 @@ module.exports = {
|
||||
template: '../packages/dapps/index.ejs',
|
||||
favicon: FAVICON,
|
||||
secure: dapp.secure,
|
||||
chunks: [ !isProd || dapp.commons ? 'commons' : null, dapp.url ]
|
||||
chunks: [ dapp.url ]
|
||||
});
|
||||
});
|
||||
|
||||
let plugins = Shared.getPlugins().concat(
|
||||
new WebpackErrorNotificationPlugin()
|
||||
new WebpackErrorNotificationPlugin(),
|
||||
new ExtractTextPlugin({
|
||||
filename: 'styles/[name].[hash:10].css',
|
||||
allChunks: true
|
||||
})
|
||||
);
|
||||
|
||||
if (!isEmbed) {
|
||||
@@ -221,10 +216,7 @@ module.exports = {
|
||||
filename: 'index.html',
|
||||
template: './index.ejs',
|
||||
favicon: FAVICON,
|
||||
chunks: [
|
||||
isProd ? null : 'commons',
|
||||
'index'
|
||||
]
|
||||
chunks: [ 'index' ]
|
||||
}),
|
||||
|
||||
new ServiceWorkerWebpackPlugin({
|
||||
@@ -233,16 +225,6 @@ module.exports = {
|
||||
|
||||
DappsHTMLInjection,
|
||||
|
||||
new webpack.DllReferencePlugin({
|
||||
context: '.',
|
||||
manifest: require(`../${DEST}/vendor-manifest.json`)
|
||||
}),
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
sync: [ 'commons', 'vendor.js' ],
|
||||
defaultAttribute: 'defer'
|
||||
}),
|
||||
|
||||
new CopyWebpackPlugin([
|
||||
{ from: './error_pages.css', to: 'styles.css' },
|
||||
{ from: '../packages/dapps/static' }
|
||||
@@ -257,10 +239,7 @@ module.exports = {
|
||||
filename: 'embed.html',
|
||||
template: './index.ejs',
|
||||
favicon: FAVICON,
|
||||
chunks: [
|
||||
isProd ? null : 'commons',
|
||||
'embed'
|
||||
]
|
||||
chunks: [ 'embed' ]
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -273,12 +252,6 @@ module.exports = {
|
||||
// messagesPattern: DEST_I18N + '/i18n/**/*.json',
|
||||
// aggregateOutputDir: DEST_I18N + '/i18n/',
|
||||
// aggregateFilename: 'en'
|
||||
// }),
|
||||
//
|
||||
// new webpack.optimize.CommonsChunkPlugin({
|
||||
// filename: 'commons.[hash:10].js',
|
||||
// name: 'commons',
|
||||
// minChunks: 2
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
|
||||
@@ -19,7 +19,6 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
||||
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
||||
const PackageJson = require('../package.json');
|
||||
|
||||
const UI_VERSION = PackageJson
|
||||
@@ -36,7 +35,6 @@ const UI_VERSION = PackageJson
|
||||
const EMBED = process.env.EMBED;
|
||||
const ENV = process.env.NODE_ENV || 'development';
|
||||
const isProd = ENV === 'production';
|
||||
const isAnalize = process.env.WPANALIZE === '1';
|
||||
|
||||
function getBabelrc () {
|
||||
const babelrc = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../.babelrc')));
|
||||
@@ -73,34 +71,19 @@ function getBabelrc () {
|
||||
}
|
||||
|
||||
function getPlugins (_isProd = isProd) {
|
||||
const plugins = (isAnalize
|
||||
? []
|
||||
: [
|
||||
new ProgressBarPlugin({
|
||||
format: '[:msg] [:bar] ' + ':percent' + ' (:elapsed seconds)'
|
||||
})
|
||||
]).concat([
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
EMBED: JSON.stringify(EMBED),
|
||||
NODE_ENV: JSON.stringify(ENV),
|
||||
RPC_ADDRESS: JSON.stringify(process.env.RPC_ADDRESS),
|
||||
PARITY_URL: JSON.stringify(process.env.PARITY_URL),
|
||||
DAPPS_URL: JSON.stringify(process.env.DAPPS_URL),
|
||||
LOGGING: JSON.stringify(!isProd),
|
||||
UI_VERSION: JSON.stringify(UI_VERSION)
|
||||
}
|
||||
}),
|
||||
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
minimize: isProd,
|
||||
debug: !isProd,
|
||||
options: {
|
||||
context: path.join(__dirname, '../src'),
|
||||
babel: getBabelrc()
|
||||
}
|
||||
})
|
||||
]);
|
||||
const plugins = [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
EMBED: JSON.stringify(EMBED),
|
||||
NODE_ENV: JSON.stringify(ENV),
|
||||
RPC_ADDRESS: JSON.stringify(process.env.RPC_ADDRESS),
|
||||
PARITY_URL: JSON.stringify(process.env.PARITY_URL),
|
||||
DAPPS_URL: JSON.stringify(process.env.DAPPS_URL),
|
||||
LOGGING: JSON.stringify(!isProd),
|
||||
UI_VERSION: JSON.stringify(UI_VERSION)
|
||||
}
|
||||
})
|
||||
];
|
||||
|
||||
if (_isProd) {
|
||||
plugins.push(
|
||||
@@ -130,6 +113,8 @@ function getDappsEntry () {
|
||||
const builtins = require('@parity/shared/config/dappsBuiltin.json');
|
||||
const views = require('@parity/shared/config/dappsViews.json');
|
||||
|
||||
return {};
|
||||
|
||||
return Object.assign(
|
||||
[]
|
||||
.concat(
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
|
||||
const Shared = require('./shared');
|
||||
|
||||
const ENV = process.env.NODE_ENV || 'development';
|
||||
const DEST = process.env.BUILD_DEST || '.build';
|
||||
|
||||
let modules = [
|
||||
'bignumber.js',
|
||||
'blockies',
|
||||
'brace',
|
||||
'browserify-aes',
|
||||
'ethereumjs-tx',
|
||||
'lodash',
|
||||
'material-ui',
|
||||
'mobx',
|
||||
'mobx-react',
|
||||
'moment',
|
||||
'phoneformat.js',
|
||||
'react',
|
||||
'react-dom',
|
||||
'react-redux',
|
||||
'react-router',
|
||||
'react-router-redux',
|
||||
'recharts',
|
||||
'redux',
|
||||
'redux-thunk',
|
||||
'semantic-ui-css',
|
||||
'semantic-ui-react',
|
||||
'scryptsy',
|
||||
'zxcvbn'
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
vendor: modules
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.json$/,
|
||||
use: [ 'json-loader' ]
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
include: /(ethereumjs-tx)/,
|
||||
use: [ 'babel-loader' ]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
resolve: {
|
||||
alias: {
|
||||
'~': path.resolve(__dirname, '..')
|
||||
}
|
||||
},
|
||||
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: path.resolve(__dirname, '../', `${DEST}/`),
|
||||
library: '[name]_lib'
|
||||
},
|
||||
plugins: Shared.getPlugins().concat([
|
||||
new webpack.DllPlugin({
|
||||
name: '[name]_lib',
|
||||
path: path.resolve(__dirname, '../', `${DEST}/[name]-manifest.json`)
|
||||
}),
|
||||
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
NODE_ENV: JSON.stringify(ENV)
|
||||
}
|
||||
})
|
||||
])
|
||||
};
|
||||
Reference in New Issue
Block a user