Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update with path error #67

Closed
DemonCloud opened this issue Oct 14, 2017 · 9 comments
Closed

Update with path error #67

DemonCloud opened this issue Oct 14, 2017 · 9 comments

Comments

@DemonCloud
Copy link

DemonCloud commented Oct 14, 2017

2017-10-14 6 39 51

The path:

http://dll/vendors.de52e9e4.js net::ERR_NAME_NOT_RESOLVED

if visit the path currently

http://localhost:9001/dll/vendors.de52e9e4.js

2017-10-14 6 42 37

my webpack pack js config

// Webpack [JS]

// * use to pack minify Javascript
// * babel to preset ES6 => ES5
// * Optimize with CommonsChunkPlugin()
// * minify Javascript

// @exports [rules]
// @exports [plugins]
'use strict';

const ISDEV = process.env.NODE_ENV === 'development';

const webpack = require('webpack');
const HappyPack = require('happypack');
const HappyThreadPool = HappyPack.ThreadPool({ size: 8 });

const path = require('./pack.path');
const config = require('./pack.config');
const rpath = require('path');
const resolve = rpath.resolve;

const BabiliPlugin = require('babili-webpack-plugin');
const AutoDLLPlugin = require('autodll-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
// const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');

const PRDTASK = ISDEV ? [
	new webpack.NoEmitOnErrorsPlugin(),
	new webpack.HotModuleReplacementPlugin(),
	new webpack.NamedModulesPlugin(),
	// fast building with AutoDllPlugin
	new AutoDLLPlugin({
		inject: true,
		debug: ISDEV,
		filename: '[name].[hash:8].js',
		path: 'dll',
		entry: {
			vendors : config.vendors
		}
	})
	// new FriendlyErrorsPlugin()
	// new InterpolateHtmlPlugin()
] : [
	// Generate a manifest file which contains a mapping of all asset filenames
	// to their corresponding output file so that tools can pick it up without
	// having to parse `index.html`.
	new BabiliPlugin(),

	new webpack.LoaderOptionsPlugin({
		minimize: true,
		debug: false
	}),
	new webpack.optimize.MinChunkSizePlugin({
		minChunkSize: 10240
	}),
	new webpack.optimize.CommonsChunkPlugin({
		name: config.commonChunkName,
		chunks: path.chunks,
		filename: 'common/[name].[hash:8].js',
		minChunks: function(module){
			return module.context && (
						module.context.indexOf('node_modules') !== -1 ||
						module.context.indexOf('dist/common') !== -1 ||
						module.context.indexOf('dist/style') !== -1);
		}
	}),
	new webpack.optimize.AggressiveMergingPlugin(),
	new webpack.optimize.OccurrenceOrderPlugin(),
	new webpack.optimize.ModuleConcatenationPlugin(),
	new ParallelUglifyPlugin({
		test: /.(js|jsx)$/,
		exclude: /node_modules/,
		cacheDir: "./node_modules/.cache/",
		workerCount: 6,
		sourceMap: false,
		uglifyJS: {
			compress: {
				unsafe: true,
				warnings: false,
				hoist_vars: true,
				drop_console: true,
				collapse_vars: true,
				reduce_vars: true
			},
			sourceMap: false,
			mangle: false
		},
	})
	// new webpack.optimize.UglifyJsPlugin({
	// 	compress: {
	// 		unsafe: true,
	// 		warnings: false,
	// 		hoist_vars: true,
	// 		drop_console: true,
	// 		collapse_vars: true,
			// reduce_vars: true
	// 	},
	// 	beautify: false,
	// 	comments: false,
	// 	sourceMap: false,
	// 	mangle: false
	// }),
];

module.exports = {
	rules: [
		{
			test: /\.(js|jsx)$/,
			use: 'happypack/loader?id=jsx',
			exclude: /node_modules/,
		},

		// {
		// 	test: /\.(js|jsx)$/,
		// 	exclude: /node_modules|assets/,
		// 	use: (ISDEV ? [{ loader: "react-hot-loader/webpack" }] : []).concat([
		// 		{
		// 			loader: "babel-loader",
		// 			options: {
		// 				babelrc: false,
		// 				presets: ["es2015","react"],
		// 				plugins: ISDEV ?
		// 				['transform-runtime','transform-class-properties','transform-function-bind','transform-do-expressions'] :
		// 				['transform-class-properties','transform-function-bind','transform-do-expressions'],
		// 				compact: true,
		// 				cacheDirectory: true
		// 			},
		// 		}
		// 	]),
		// },

		// doom template to module
		{
			test: /\.doom$/,
			use: 'happypack/loader?id=doom',
			exclude: /node_modules/
		},
	],

	plugins: [
		new HappyPack({
			id: "jsx",
			threadPool: HappyThreadPool,
			loaders: [
				{
					loader: 'cache-loader',
					query: {
						cacheDirectory: path.cache
					}
				},
				{
					loader: 'babel-loader',
					query: {
						babelrc: false,
						presets: ["es2015","react"],
						plugins: ISDEV ?
						['transform-runtime','transform-class-properties','transform-function-bind','transform-do-expressions'] :
						['transform-class-properties','transform-function-bind','transform-do-expressions'],
						compact: true,
						cacheDirectory: true
					}
				}
			]
		}),
		new HappyPack({ id: "doom", loaders: ['raw-loader'] }),
		// new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn|en-gb/),
		new ManifestPlugin({ fileName: 'manifest.json' }),
		new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
		new webpack.DefinePlugin(config.defined),
		new webpack.ProvidePlugin(config.provide),

		new NpmInstallPlugin(),
		new WatchMissingNodeModulesPlugin(resolve('node_modules')),
		new CaseSensitivePathsPlugin(),
	].concat(PRDTASK)
};
@asfktz
Copy link
Owner

asfktz commented Oct 14, 2017

Hi @DemonCloud, Thanks for reporting,

I assume that you merge that config with some other config?
I need to see the output option of it

@DemonCloud
Copy link
Author

DemonCloud commented Oct 14, 2017

@asfktz

under dev mode

Webpack version 3.7.1

  const _ = path.resolve('./');
  const _dist = `${_}/dist`;

	output: {
		path: _dist,
		filename: '[name].[hash:8].js',
		// chunkFilename: '[name].[chunkhash:8].js',
		publicPath: '/'
	}

@asfktz
Copy link
Owner

asfktz commented Oct 14, 2017

Do you use version 0.3.1?
Is so, can you try version 0.2.1 and tell me if still get an error?

@DemonCloud
Copy link
Author

@asfktz

I use version 0.3.1

0.2.1 work currently~~!

2017-10-14 8 00 53

@asfktz
Copy link
Owner

asfktz commented Oct 14, 2017

Awesome (:
So use it for now while I figure out what's broken with 0.3.1
One more thing, what OS and Node.js version are you using?

@DemonCloud
Copy link
Author

@asfktz

Sorry, I forget it ~

Node 8.7.0
macOS High Sierra 10.13

use Yarn for the package manager

@ghost
Copy link

ghost commented Oct 15, 2017

Hi @asfktz , thanks for this plugin!
I got the same error for v0.3.1, but it's work correctly with publicPath: './'.
I think this may be related to jfromaniello/url-join#16

@asfktz
Copy link
Owner

asfktz commented Oct 15, 2017

Spot on, @surmin2005
It was exactly it, thanks!

I released a new version, 0.3.2.

@DemonCloud, can you check if it works for you now?

@DemonCloud
Copy link
Author

@asfktz

it works currently! thanks

@asfktz asfktz closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants