首先很抱歉粘贴这个丑陋的构建失败日志...但我很沮丧。我可以看到来自ld-redux
uuid
的失败,然后以某种方式进入crypto-browserify/test
,任何有类似问题的人都可以帮忙吗?
非常感谢
ERROR in ./~/crypto-browserify/test/create-hash.js
Module not found: Error: Can't resolve 'tape' in '/Users/billluo/Git/assurewebsite/node_modules/crypto-browserify/test'
@ ./~/crypto-browserify/test/create-hash.js 1:11-26
@ ./~/crypto-browserify/index.js
@ ./~/node-uuid/uuid.js
@ ./~/ld-redux/lib/init.js
@ ./~/ld-redux/lib/index.js
@ ./src/universal/domain/health/products/combinedProducts.js
@ ./src/universal/routes.js
@ ./src/client/index.js
@ multi babel-polyfill webpack-dev-server/client?http://192.168.2.51:8001 webpack/hot/only-dev-server ./src/client/index
ERROR in ./~/crypto-browserify/test/create-hmac.js
Module not found: Error: Can't resolve 'tape' in '/Users/billluo/Git/assurewebsite/node_modules/crypto-browserify/test'
@ ./~/crypto-browserify/test/create-hmac.js 1:11-26
@ ./~/crypto-browserify/index.js
@ ./~/node-uuid/uuid.js
@ ./~/ld-redux/lib/init.js
@ ./~/ld-redux/lib/index.js
@ ./src/universal/domain/health/products/combinedProducts.js
@ ./src/universal/routes.js
@ ./src/client/index.js
@ multi babel-polyfill webpack-dev-server/client?http://192.168.2.51:8001 webpack/hot/only-dev-server ./src/client/index
ERROR in ./~/crypto-browserify/test/pbkdf2.js
Module not found: Error: Can't resolve 'tape' in '/Users/billluo/Git/assurewebsite/node_modules/crypto-browserify/test'
@ ./~/crypto-browserify/test/pbkdf2.js 1:11-26
@ ./~/crypto-browserify/index.js
@ ./~/node-uuid/uuid.js
@ ./~/ld-redux/lib/init.js
@ ./~/ld-redux/lib/index.js
@ ./src/universal/domain/health/products/combinedProducts.js
@ ./src/universal/routes.js
@ ./src/client/index.js
@ multi babel-polyfill webpack-dev-server/client?http://192.168.2.51:8001 webpack/hot/only-dev-server ./src/client/index
ERROR in ./~/crypto-browserify/test/public-encrypt.js
Module not found: Error: Can't resolve 'tape' in '/Users/billluo/Git/assurewebsite/node_modules/crypto-browserify/test'
@ ./~/crypto-browserify/test/public-encrypt.js 1:11-26
@ ./~/crypto-browserify/index.js
@ ./~/node-uuid/uuid.js
@ ./~/ld-redux/lib/init.js
@ ./~/ld-redux/lib/index.js
@ ./src/universal/domain/health/products/combinedProducts.js
@ ./src/universal/routes.js
@ ./src/client/index.js
@ multi babel-polyfill webpack-dev-server/client?http://192.168.2.51:8001 webpack/hot/only-dev-server ./src/client/index
这是我的构建脚本
import autoprefixer from 'autoprefixer';
import path from 'path';
import webpack from 'webpack';
import AssetsPlugin from 'assets-webpack-plugin';
import config from 'config';
import ipAddress from '../../src/universal/utils/ipAddress';
const root = path.resolve(__dirname, '..', '..');
const appSourceFolder = path.resolve(root, 'src');
const devServerUrl = `http://${ipAddress}:${config.port + 1}`;
// We use SVGO to optimise the imported SVG files
const svgoConfig = JSON.stringify({
plugins: [
{removeTitle: true},
{removeAttrs: {attrs: 'fill'}},
],
});
export default {
devtool: 'source-map', // Note: changed from cheap-module-inline-source-map to eval-source-map due to issues setting breakpoints reliably
debug: true, // switch loaders to debug mode
entry: [
'babel-polyfill',
`webpack-dev-server/client?${devServerUrl}`,
'webpack/hot/only-dev-server',
'./src/client/index',
],
target: 'web',
output: {
path: path.resolve(root, 'dist'),
pathinfo: true, // Add /* filename */ comments to generated require()s in the output.
filename: 'bundle.js',
publicPath: `${devServerUrl}/dist/`,
},
externals: [{
config: 'config',
}],
resolve: {
extensions: ['', '.js', '.json'],
modulesDirectories: [
'assets',
'src',
'test',
'node_modules',
],
},
module: {
// run eslint before compiling
preLoaders: [
{
test: /\.js$/,
loader: 'eslint-loader',
include: appSourceFolder,
exclude: /node_modules/,
},
],
loaders: [
{
test: /\.js$/,
include: appSourceFolder,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['react-hmre'],
},
},
{
test: /\.json/,
loaders: ['json'],
},
{
test: /\.sass$/,
loaders: [
'style?sourceMap',
'css?sourceMap&modules&importLoaders=3&localIdentName=[folder]--[local]--[hash:base64:2]',
'resolve-url',
'postcss',
'sass?sourceMap',
],
},
{
test: /\.(ico|jpg|png|gif|eot|ttf|woff|woff2)(\?.*)?$/,
loader: 'url',
query: {
limit: 5000,
name: 'static/[name]-[hash:6].[ext]',
},
},
// icons loader
{
test: /icon\.svg$/,
loaders: ['babel', 'svg-react', `svgo?${svgoConfig}`],
},
// svg loader excluding the .icon.svg files
{
test: /^(?!.*icon\.svg$).*\.svg$/,
loaders: ['url?limit=5000'],
},
{
test: /\.html$/,
loaders: ['html-loader'],
},
],
},
postcss: () => [autoprefixer({browsers: ['last 2 versions', 'ie > 9']})],
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.ProvidePlugin({
React: 'react', // provides React globally so that we don't need to import it
cssModules: 'react-css-modules',
classnames: 'classnames',
Logger: 'universal/utils/log',
}),
// outputs a json file with the paths of the generated assets
new AssetsPlugin({
filename: 'webpack-assets.json',
path: path.resolve(root, 'dist'),
}),
new webpack.DefinePlugin({
__IS_BROWSER__: true,
}),
],
};