I am currently trying to run webpack with the mand set NODE_ENV=production && webpack
(Window User) But there was no output within the src directory with the name bundle.js, in fact there was no output file.
I have only used webpack-dev-server until now, so this is the first time I try to build a config file with plugins. webpack-dev-server as I have tried, is running okay.
src folder contains all my files including html and javascript.
I need an output files with working minified and pressed codes. Please assist and advise!!
The below was found in the terminal
Hash: 09ea2200290287327c75
Version: webpack 1.13.2
Time: 6976ms
Asset Size Chunks Chunk Names
bundle.js 3.48 MB 0 [emitted] main
[0] multi main 28 bytes {0} [built]
[1] ./src/index.js 2.73 kB {0} [built]
+ 12 hidden modules
I do have a webpack.config.js file that has the below config.
const path = require('path');
const webpack = require('webpack');
const debug = process.env.NODE_ENV !== "production";
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: path.resolve(__dirname,'/src'),
filename: 'bundle.js'
},
devtool: debug ? "inline-sourcemap" : null,
module: {
loader: [{
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['angular']
}
}]
},
devServer: {
historyApiFallback: true,
contentBase: 'src'
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
press: { warnings: false }
})
]
};
I am currently trying to run webpack with the mand set NODE_ENV=production && webpack
(Window User) But there was no output within the src directory with the name bundle.js, in fact there was no output file.
I have only used webpack-dev-server until now, so this is the first time I try to build a config file with plugins. webpack-dev-server as I have tried, is running okay.
src folder contains all my files including html and javascript.
I need an output files with working minified and pressed codes. Please assist and advise!!
The below was found in the terminal
Hash: 09ea2200290287327c75
Version: webpack 1.13.2
Time: 6976ms
Asset Size Chunks Chunk Names
bundle.js 3.48 MB 0 [emitted] main
[0] multi main 28 bytes {0} [built]
[1] ./src/index.js 2.73 kB {0} [built]
+ 12 hidden modules
I do have a webpack.config.js file that has the below config.
const path = require('path');
const webpack = require('webpack');
const debug = process.env.NODE_ENV !== "production";
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: path.resolve(__dirname,'/src'),
filename: 'bundle.js'
},
devtool: debug ? "inline-sourcemap" : null,
module: {
loader: [{
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['angular']
}
}]
},
devServer: {
historyApiFallback: true,
contentBase: 'src'
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
press: { warnings: false }
})
]
};
Share
Improve this question
asked Sep 21, 2016 at 11:38
Winson LiaoWinson Liao
1032 silver badges8 bronze badges
1 Answer
Reset to default 6This doesn't do what you are expecting:
path : path.resolve(__dirname, '/src')
Because it resolves to /src
, and not—as you probably expected—"src/
in the current directory".
For that, use this:
path : path.resolve(__dirname, 'src')
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745635649a4637375.html
评论列表(0条)