Closed dmitriid closed 6 years ago
same problem
:+1:
same problem about 'removed by extract-text-webpack-plugin'
the same
Does anyone has a solution / workaround? Is this plugin even mantained?
What I've found is that the JS section for the CSS is extracted into it's own file, but the source map ends up getting wiped out. The resolution to this was to add "?sourceMap" to the "css-loader".
The problem I found with this is that it mangles the source names in the source map. Not sure what to do about that yet.
same problem
Okay folks, any updates or workarounds may be with another plugins for css? Same problem here.
Same problem. any workaround?
Okay, what worked for me is:
good:
entry: { js: './js/app.js', css: './scss/main.scss' },
bad:
entry: { js: './js/app.js', scss: './scss/main.scss' }
the only difference - css
key instead of scss
. And also
entry: [ './js/main.js', './scss/main.scss' ],
works too.
Did you have sourcemaps enabled? That appears to be the hitch.
I'm getting something really weird
and webpack config parts
const CSS_LOADER = `css?sourceMap&modules&importLoaders=1&${LOCAL_IDENT_NAME}?root=${ROOT_PUBLIC}!postcss-loader!sass?sourceMap!toolbox`;
...
module.exports = {
entry: [
'babel-polyfill',
'./src/bootstrap',
'./src/scss/global.scss'
],
output: {
filename: 'bootstrap.js',
path: path.join(__dirname, PATH)
},
...
// Load SCSS
{
test: /\.scss$/,
loader: `style!${CSS_LOADER}` // ExtractTextPlugin.extract('style', CSS_LOADER)
},
I even tried to remove ExtractTextPlugin entirely but still getting same errors. Also found that on production build with this - all works fine
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new ExtractTextPlugin('style.css', {
allChunks: true
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
screw_ie8: true,
keep_fnames: true,
warnings: false
},
mangle: {
screw_ie8: true,
keep_fnames: true
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin()
],
Same goes for eval - *
devtool config likecheap-module-eval-source-map
. all works fine...
weird. anyone has idea what could be causing this?
try:
filename: "[name].js"
Anybody else find a solution for this?
scythargon commented on 3 Jun 2016
it's work for me, thanks!
@dmitriid @mrsum @TrejGun @preschian @olegggI @redhead @codisms @fezhengjin @scythargon @ryanbagwell problem still exists?
I personally haven't used the plugin since :)
I moved away from JavaScript :D
Looks like this is caused by having a JS file with the same entry name as your CSS/LESS file. I just suffix the less items with "-less" to work around it. Not a very well-written module. But this is JavaScript after all.
This occurred to me in Rails 5.1 using webpacker with the default configuration (which I assume will lead more people to this issue soon :) It's used here in rails/webpacker.
I can confirm that if you have e.g. admin.sass
and admin.js
, the latter will be stripped of all content. Renaming one of the files is a workaround as @jonwingfield noted.
As of Rails 5.2 (webpacker 3.5), if the JS pack contains CSS, the CSS will be extracted into a CSS pack with the same name. So both packs need to be referenced in Rails even if only the JS pack is defined.
Just posting this as I thought I ran into the reported issue, but perhaps it is only a gotcha with similar symptoms.
@prusswan what exactly do you mean 'referenced in Rails'? Would you mind pasting a small code snippet to elaborate? I'm having a lot of trouble including CSS from node_modules
for one of my components and have yet to find a solution better than including it at the application.js
level.
@colintsteele Just javascript_pack_tag
and stylesheet_pack_tag
etc. See https://github.com/prusswan/d3ia-2e/commit/fd3534aca1fcb051d700b6e966664eeecfeba7bc
I noticed this behavior after seeing that all the CSS stuff is "removed" in the JS pack, and checking the output files in public/packs
. It makes sense but probably better documentation (at the rails/webpacker side) would help for Rails users who are new to webpack and the default configuration put in place by rails/webpacker
..
TL;DR: when generating two .js and one .css chunks the plugin removes all .js code from one of the .js chunks.
I may be missing something, but I can't find what it is :)
The config is as follows:
When running
webpack
, this is the output:As a result:
css.css
contains all css, as requiredlib.js
contains all lib code, as requiredapp.js
: every single entry inapp.js
is replaced with