Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

html-webpack-inline-source-plugin报错

var pkg = require('./package.json');

var path = require('path');

var webpack = require('webpack');

var HtmlWebpackPlugin = require('html-webpack-plugin');

var HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');

var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports =?{

entry: {

app: path.resolve(__dirname, 'app/index.jsx'),

//?将?第三方依赖(node_modules中的)?单独打包

vendor: Object.keys(pkg.dependencies),

},

output: {

path: __dirname + '/build',

filename: '/Tools/js/[name].[chunkhash:8].js',

},

resolve: {

extensions: ['', '.js', '.jsx'],

},

module: {

loaders: [

{ test: /.(js|jsx)$/, exclude: /node_modules/, loader: 'babel' },

{

test: /.less$/,

exclude: /node_modules/,

loader: ExtractTextPlugin.extract('style', 'css!postcss!less'),

},

{

test: /.css$/,

exclude: /node_modules/,

loader: ExtractTextPlugin.extract('style', 'css!postcss'),

},

{

test: /.(png|gif|jpg|jpeg|bmp)$/i,

loader: 'url-loader?limit=5000&name=/Tools/img/[name].[hash:8].[ext]',

},

{

test: /.(woff|woff2|svg|ttf|eot)($|?)/i,

loader: 'url-loader?limit=5000&name=/Tools/fonts/[name].[hash:8].[ext]',

},

],

},

postcss: [require('autoprefixer')],

plugins: [

//?//?webpack?内置的?banner-plugin

//?new?webpack.BannerPlugin('Copyright?by?amillet晏'),/*??*/

//?定义为生产环境,编译?React?时压缩到最小

new webpack.DefinePlugin({

'process.env': {

NODE_ENV: JSON.stringify(process.env.NODE_ENV),

},

}),

//?为组件分配ID,通过这个插件webpack可以分析和优先考虑使用最多的模块,并为它们分配最小的ID

new webpack.optimize.OccurenceOrderPlugin(),

new webpack.optimize.UglifyJsPlugin({

compress: {

//supresses?warnings,?usually?from?module?minification

warnings: false,

drop_console: true,

},

}),

//?分离CSS和JS文件

new ExtractTextPlugin('/Tools/css/[name].[chunkhash:8].css'),

//?提供公共代码

new webpack.optimize.CommonsChunkPlugin({

name: 'vendor',

filename: '/Tools/js/[name].[chunkhash:8].js',

}),

//?可在业务?js?代码中使用?__DEV__?判断是否是dev模式(dev模式下可以提示错误、测试报告等,?production模式不提示)

new webpack.DefinePlugin({

__DEV__: JSON.stringify(

JSON.parse(process.env.NODE_ENV == 'dev' || 'false')

),

}),

new webpack.DefinePlugin({

'process.env': {

NODE_ENV: JSON.stringify('production'),

},

}),

//?html?模板插件

new HtmlWebpackPlugin({

template: __dirname + '/app/index.tmpl.html',

inlineSource: '.(js|css)$',

filename: 'webglviewer.html',

}),

new HtmlWebpackInlineSourcePlugin(),

],

};

image
npm run build后报错,求大神解决


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...