Angularjs 通过grunt Webpack运行的Webpack不';不要出错或完成,或做任何事情
尝试使用webpack和grunt webpack将旧系统从bower转换为npm。只需尝试使用webpack加载NPM文件,而不运行其他任何操作,grunt文件的其余部分就完成了加载、丑化等操作,并运行自己的节点服务器。到了这一点,它冻结了,再也不会回来了Angularjs 通过grunt Webpack运行的Webpack不';不要出错或完成,或做任何事情,angularjs,webpack,gruntjs,Angularjs,Webpack,Gruntjs,尝试使用webpack和grunt webpack将旧系统从bower转换为npm。只需尝试使用webpack加载NPM文件,而不运行其他任何操作,grunt文件的其余部分就完成了加载、丑化等操作,并运行自己的节点服务器。到了这一点,它冻结了,再也不会回来了 Loading "grunt-webpack" plugin Registering "/Users/***/***/***/node_modules/grunt-webpack/tasks" tasks. Loading "webpac
Loading "grunt-webpack" plugin
Registering "/Users/***/***/***/node_modules/grunt-webpack/tasks" tasks.
Loading "webpack-dev-server.js" tasks...OK
+ webpack-dev-server
Loading "webpack.js" tasks...OK
+ webpack
Running "webpack" task
这是我的grunt代码(显然是超基本的)
这是开发文件
const webpack = require('webpack');
const helpers = require('./helpers');
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { BaseHrefWebpackPlugin } = require('base-href-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ConcatPlugin = require('webpack-concat-plugin');
const ngInventory = require('./ng1-vendor-index.js');
const common = require('./webpack.common.js');
const ENV = process.env.NODE_ENV = process.env.ENV = 'dev';
module.exports = merge(common(ENV), {
devtool: 'source-map',
module: {
rules: [
{
test: /\.(ts|js)$/,
loaders: ['angular-router-loader'],
},
{
test: /\.((s*)css)$/,
use: [{
loader: 'style-loader',
},{
loader: 'css-loader',
},{
loader: 'sass-loader',
}]
},
{
test: /src\/.+\.(ts|js)$/,
exclude: /(node_modules|\.spec\.ts$)/,
loader: 'istanbul-instrumenter-loader',
enforce: 'post',
options: {
esModules: true
}
}
]
},
debug: true,
devTool: 'eval',
plugins: [
new ConcatPlugin({
uglify: false,
sourceMap: true,
name: 'vendor',
outputPath: './',
fileName: '[name].[hash].js',
filesToConcat: ngInventory.vendor1
}),
new BaseHrefWebpackPlugin({ baseHref: '/'}),
new HtmlWebpackPlugin({
favicon: helpers.root('client/assets/image/favicon.png'),
template: "./client/index.html",
filename: "./client/index.html",
}),
new webpack.NoEmitOnErrorsPlugin(),
],
});
以下是通用文件:
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals')
const helpers = require('./helpers');
module.exports = env => ({
entry: {
server: './server/app.js',
},
resolve: {
extensions: ['.ts', '.js']
},
output: {
path: helpers.root(`dist/${env}`),
publicPath: '/',
filename: '[name].js'
},
target: 'node',
node: {
// Need this when working with express, otherwise the build fails
__dirname: false, // if you don't put this is, __dirname
__filename: false, // and __filename return blank or /
},
externals: [nodeExternals()],
module: {
rules: [
{
// Transpiles ES6-8 into ES5
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.html$/,
include: [
helpers.root('client'),
],
loader: 'html-loader'
},
{
test: /\.((s*)css)%/,
include: [
helpers.root('client/app'),
helpers.root('client/components'),
],
exclude: 'node_modules/',
loaders: ['to-string-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(woff|woff2|eot|tts)$/,
use: [{
loader: 'file-loader'
}]
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(env)
}
}),
new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)esm5/, path.join(__dirname, './client')),
]
});
供应商索引文件中的示例:
const helper = require('./helpers');
exports.vendor1 = [
helper.root('node_modules/lodash/lodash.js'),
helper.root('node_modules/lodash-deep/lodash-deep.js'),
...
...
]
我真的不知道该怎么办,无法显示任何谷歌结果或堆栈结果,因为也没有发生错误。我尝试了所有详细级别的日志记录,但都没有用。我到底缺少什么?如图所示,您还没有配置任何目标,如dev
或prod
。您只指定了选项
。你想要
webpack: {
options: {},
dev: require("./config/webpack.dev.js"),
},
顺便说一句,使用带有Grunt的Webpack没有任何好处 亲爱的耶稣,如果这是我错过的,我可能会头撞到墙。是的,我所要做的就是将新组件从npm而不是bower写入索引文件。这可能是过度工程化了。可能是你交过的最简单的100次代表。
webpack: {
options: {},
dev: require("./config/webpack.dev.js"),
},