webpack中文

Use NODE_ENV in source code to control build process with Webpack

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am setting up Redux DevTools ( https://www.npmjs.com/package/redux-devtools ) in my project and want to exclude the DevTools when building my project for production. The documentation says that this can be accomplished by using this code: if ( process . env . NODE_ENV === 'production' ) { module . exports = require ( './configureStore.prod' ); } else { module . exports = require ( './configureStore.dev' ); } I already have a module with constants so I have put the checking for the NODE_ENV in there. Constants . PRODUCTION =

webpack sass-loader not generating a css file

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I can't figure out how to render a css file with the webpack sass-loader. Here's what my webpackconfig.js looks like: module.exports = { context: __dirname + "/app", entry: { javascript: "./app.js", html: "./index.html" }, output: { filename: "app.js", path: __dirname + "/dist" }, module: { loaders: [ //JAVASCRIPT { test: /\.js$/, exclude: /node_modules/, loaders: ["babel-loader"], }, //Index HMTML { test: /\.html$/, loader: "file?name=[name].[ext]", }, //Hotloader { test: /\.js$/, exclude: /node_modules/, loaders: ["react-hot", "babel

How to use jest with webpack?

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use webpack to develop a React component. Here is a simple version of it: 'use strict'; require('./MyComponent.less'); var React = require('react'); var MyComponent = React.createClass({ render() { return ( Hello World ); } }); module.exports = MyComponent; Now, I would like to test this component using jest . Here is the relevant bit from my package.json : "scripts": { "test": "jest" }, "jest": { "rootDir": ".", "testDirectoryName": "tests", "scriptPreprocessor": " /node_modules/babel-jest", "unmockedModulePathPatterns": [ "react" ] }

window not defined error when using extract-text-webpack-plugin React

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using webpack to build my react components and I'm trying to use the extract-text-webpack-plugin to separate my css from my generated js file. However, when I attempt to build the component I get the following error: Module build failed: ReferenceError: window is not defined . My webpack.config.js file looks like this: var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); module.exports = { entry: { MainComponent: './src/main.js' }, output: { libraryTarget: 'var', library: 'MainComponent', path

SCRIPT1002: Syntax error in IE11 with React + Babel + Webpack

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to get my React App with ES2015 functionalities running in IE >= 11 using Webpack + Babel. The setup is custom, using the inferno-compat layer, so no create-react-app used here. However - despite applying the latest babel-polyfill and babel-preset-env practices to my .babelrc and webpack config, I still get a SCRIPT1002: Syntax error within my bundle.js when trying to access the app with IE11. When I follow the syntax error reference in IEs console, this is the part within the generated bundle.js that's conflicting (the arrow

Webpack hmr: __webpack_hmr 404 not found

匿名 (未验证) 提交于 2019-12-03 01:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using webpack-dev-server for hot module replacement. It's working just fine, but this error keeps showing up in the console every couple of seconds: GET http://mysite:8080/__webpack_hmr 404 (Not Found) . Here's my webpack.config.js: var webpack = require('webpack'), hostname = 'mysite', port = 8080; module.exports = { entry: [ 'babel-polyfill', './src/js/main.js', './dev/requireCss.js', 'webpack/hot/dev-server', // I'm assuming the fault lies in the following line, but I can't figure out what's wrong 'webpack-hot-middleware/client?path

Unexpected token import with Webpack and Babel

匿名 (未验证) 提交于 2019-12-03 01:07:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I added react-router v4 to my project with Webpack and NodeJS. The app compiled correctly without any error messages in the log, but the browser console gave me this: Uncaught SyntaxError: Unexpected token import at Object.<anonymous> (bundle.js:3391) at __webpack_require__ (bundle.js:556) at fn (bundle.js:87) at Object.eval (eval at <anonymous> (bundle.js:1405), <anonymous>:11:25) at Object.eval (eval at <anonymous> (bundle.js:1405), <anonymous>:24:27) at eval (eval at <anonymous> (bundle.js:1405), <anonymous>:25:30) at Object.<anonymous>

UglifyJS webpack plugin throws: Unexpected token: name (features)

匿名 (未验证) 提交于 2019-12-03 01:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I used to have problems with UglifyJS for Webpack and ES6 modules: ERROR in static/js/vendor.6ccd9e38979a78765c7a.js from UglifyJs Unexpected token: name (features) [./node_modules/pica/lib/mathlib.js:19,0][static/js/vendor.6ccd9e38979a78765c7a.js:39003,6] I read that the new beta version of the Webpack plugin supports ES6: https://github.com/webpack-contrib/uglifyjs-webpack-plugin new webpack.optimize.UglifyJsPlugin({ uglifyOptions: { ie8: false, ecma: 8, // I also tried 7 and 6 parse: {}, mangle: { properties: { // mangle property options

Relative CSS urls in Webpack

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Webpack + file-loader + sass-loader is having trouble resolving relative paths for CSS background images. The compiled SCSS file contains a path to the background image that is relative to /dist/ instead of relative to the SCSS/CSS document. I researched this problem; sass-loader recommends using resolve-url-loader (with source maps). However, adding the resolve-url-loader made no difference to the compiled CSS. I have been able to resolve the issue by setting the 'publicPath' to '../..' on the file-loader. Or by disabling the 'url' setting

serverless-webpack Cannot find module &#039;./node/NodeTemplatePlugin&#039;

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use the serverless-webpack plugin , and while running webpack alone works just fine, attempting to run serverless-webpack fails with Cannot find module './node/NodeTemplatePlugin' . My serverless.yml file is as follows: service: kamehameha provider: name: aws runtime: nodejs6.10 functions: getDeltas: handler: bundle.getDeltas plugins: - serverless-webpack And my webpack config is as follows: let path = require("path") let webpack = require("webpack") let nodeExternals = require("webpack-node-externals") module.exports = { entry